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-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20221113093719.23687-3-yuancan@huawei.com>
Date:   Sun, 13 Nov 2022 09:37:19 +0000
From:   Yuan Can <yuancan@...wei.com>
To:     <mlindner@...vell.com>, <stephen@...workplumber.org>,
        <davem@...emloft.net>, <edumazet@...gle.com>, <kuba@...nel.org>,
        <pabeni@...hat.com>, <jeff@...zik.org>, <netdev@...r.kernel.org>
CC:     <yuancan@...wei.com>
Subject: [PATCH 2/2] net: sky2: Fix error handling in sky2_init_module()

A problem about modprobe sky2 failed is triggered with the following log
given:

 sky2: driver version 1.30
 debugfs: Directory 'sky2' with parent '/' already present!

The reason is that sky2_init_module() returns pci_register_driver()
directly without checking its return value, if pci_register_driver()
failed, it returns without removing sky2 debugfs and unregister
sky2_notifier, resulting the debugfs of sky2 can never be created later.

 sky2_init_module()
   sky2_debug_init() # create debugfs and register sky2_notifier
   pci_register_driver()
     driver_register()
       bus_add_driver()
         priv = kzalloc(...) # OOM happened
   # return without destroy debugfs and unregister sky2_notifier

Fix by calling sky2_debug_cleanup() when pci_register_driver() returns
error.

Fixes: 3cf267539f1f ("sky2: debug interface")
Signed-off-by: Yuan Can <yuancan@...wei.com>
---
 drivers/net/ethernet/marvell/sky2.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/marvell/sky2.c b/drivers/net/ethernet/marvell/sky2.c
index ab33ba1c3023..6996169b7ddd 100644
--- a/drivers/net/ethernet/marvell/sky2.c
+++ b/drivers/net/ethernet/marvell/sky2.c
@@ -4536,7 +4536,7 @@ static __init void sky2_debug_init(void)
 	register_netdevice_notifier(&sky2_notifier);
 }
 
-static __exit void sky2_debug_cleanup(void)
+static void sky2_debug_cleanup(void)
 {
 	if (sky2_debug) {
 		unregister_netdevice_notifier(&sky2_notifier);
@@ -5144,10 +5144,16 @@ static struct pci_driver sky2_driver = {
 
 static int __init sky2_init_module(void)
 {
+	int ret;
+
 	pr_info("driver version " DRV_VERSION "\n");
 
 	sky2_debug_init();
-	return pci_register_driver(&sky2_driver);
+	ret = pci_register_driver(&sky2_driver);
+	if (ret)
+		sky2_debug_cleanup();
+
+	return ret;
 }
 
 static void __exit sky2_cleanup_module(void)
-- 
2.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ