* [PATCH] net: wwan: call ida_free when device_register fails
@ 2022-07-08 2:02 Bo Liu
2022-07-09 3:33 ` Jakub Kicinski
2022-07-09 18:07 ` Sergey Ryazanov
0 siblings, 2 replies; 3+ messages in thread
From: Bo Liu @ 2022-07-08 2:02 UTC (permalink / raw)
To: loic.poulain, ryazanov.s.a, johannes, davem, edumazet, kuba, pabeni
Cc: netdev, linux-kernel, Bo Liu
when device_register() fails, we should call ida_free().
Signed-off-by: Bo Liu <liubo03@inspur.com>
---
drivers/net/wwan/wwan_core.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/drivers/net/wwan/wwan_core.c b/drivers/net/wwan/wwan_core.c
index b8c7843730ed..0f653e320b2b 100644
--- a/drivers/net/wwan/wwan_core.c
+++ b/drivers/net/wwan/wwan_core.c
@@ -228,8 +228,7 @@ static struct wwan_device *wwan_create_dev(struct device *parent)
wwandev = kzalloc(sizeof(*wwandev), GFP_KERNEL);
if (!wwandev) {
wwandev = ERR_PTR(-ENOMEM);
- ida_free(&wwan_dev_ids, id);
- goto done_unlock;
+ goto error_free_ida;
}
wwandev->dev.parent = parent;
@@ -242,7 +241,7 @@ static struct wwan_device *wwan_create_dev(struct device *parent)
if (err) {
put_device(&wwandev->dev);
wwandev = ERR_PTR(err);
- goto done_unlock;
+ goto error_free_ida;
}
#ifdef CONFIG_WWAN_DEBUGFS
@@ -251,6 +250,8 @@ static struct wwan_device *wwan_create_dev(struct device *parent)
wwan_debugfs_dir);
#endif
+error_free_ida:
+ ida_free(&wwan_dev_ids, id);
done_unlock:
mutex_unlock(&wwan_register_lock);
@@ -448,8 +449,7 @@ struct wwan_port *wwan_create_port(struct device *parent,
port = kzalloc(sizeof(*port), GFP_KERNEL);
if (!port) {
err = -ENOMEM;
- ida_free(&minors, minor);
- goto error_wwandev_remove;
+ goto error_free_ida;
}
port->type = type;
@@ -484,6 +484,8 @@ struct wwan_port *wwan_create_port(struct device *parent,
error_put_device:
put_device(&port->dev);
+error_free_ida:
+ ida_free(&minors, minor);
error_wwandev_remove:
wwan_remove_dev(wwandev);
--
2.27.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] net: wwan: call ida_free when device_register fails
2022-07-08 2:02 [PATCH] net: wwan: call ida_free when device_register fails Bo Liu
@ 2022-07-09 3:33 ` Jakub Kicinski
2022-07-09 18:07 ` Sergey Ryazanov
1 sibling, 0 replies; 3+ messages in thread
From: Jakub Kicinski @ 2022-07-09 3:33 UTC (permalink / raw)
To: Bo Liu
Cc: loic.poulain, ryazanov.s.a, johannes, davem, edumazet, pabeni,
netdev, linux-kernel
On Thu, 7 Jul 2022 22:02:23 -0400 Bo Liu wrote:
> Subject: [PATCH] net: wwan: call ida_free when device_register fails
> Date: Thu, 7 Jul 2022 22:02:23 -0400
> X-Mailer: git-send-email 2.18.2
>
> when device_register() fails, we should call ida_free().
We'll need a Fixes tag pointing to the commit where the problem was
introduced. Please add it above your sign-off tag and repost.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] net: wwan: call ida_free when device_register fails
2022-07-08 2:02 [PATCH] net: wwan: call ida_free when device_register fails Bo Liu
2022-07-09 3:33 ` Jakub Kicinski
@ 2022-07-09 18:07 ` Sergey Ryazanov
1 sibling, 0 replies; 3+ messages in thread
From: Sergey Ryazanov @ 2022-07-09 18:07 UTC (permalink / raw)
To: Bo Liu
Cc: Loic Poulain, Johannes Berg, David Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, netdev, open list
On Fri, Jul 8, 2022 at 5:03 AM Bo Liu <liubo03@inspur.com> wrote:
> when device_register() fails, we should call ida_free().
>
> Signed-off-by: Bo Liu <liubo03@inspur.com>
Acked-by: Sergey Ryazanov <ryazanov.s.a@gmail.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-07-09 18:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-08 2:02 [PATCH] net: wwan: call ida_free when device_register fails Bo Liu
2022-07-09 3:33 ` Jakub Kicinski
2022-07-09 18:07 ` Sergey Ryazanov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).