lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220711005319.2619-1-liubo03@inspur.com>
Date:   Sun, 10 Jul 2022 20:53:19 -0400
From:   Bo Liu <liubo03@...pur.com>
To:     <loic.poulain@...aro.org>, <ryazanov.s.a@...il.com>,
        <johannes@...solutions.net>, <davem@...emloft.net>,
        <edumazet@...gle.com>, <kuba@...nel.org>, <pabeni@...hat.com>
CC:     <netdev@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
        Bo Liu <liubo03@...pur.com>
Subject: [PATCH v2 1/1] net: wwan: call ida_free when device_register fails

when device_register() fails, we should call ida_free().

Fixes: 9a44c1cc6388 ("net: Add a WWAN subsystem")
Signed-off-by: Bo Liu <liubo03@...pur.com>
---
 Changes from v1:
 -Add a Fixes tag pointing to the commit

 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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ