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-2-yuancan@huawei.com>
Date:   Sun, 13 Nov 2022 09:37:18 +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 1/2] net: skge: Fix error handling in skge_init_module()

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

 debugfs: Directory 'skge' with parent '/' already present!
 ------------[ cut here ]------------
 notifier callback skge_device_event [skge] already registered
 WARNING: CPU: 1 PID: 236 at kernel/notifier.c:29 notifier_chain_register+0x168/0x230
 ...

The reason is that skge_init_module() returns pci_register_driver()
directly without checking its return value, if pci_register_driver()
failed, it returns without removing skge debugfs and unregister
skge_notifier, resulting the debugfs of skge can never be created later
and triggers the WARNING of notifier registered.

 skge_init_module()
   skge_debug_init() # create debugfs and register skge_notifier
   pci_register_driver()
     driver_register()
       bus_add_driver()
         priv = kzalloc(...) # OOM happened
   # return without destroy debugfs and unregister skge_notifier

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

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

diff --git a/drivers/net/ethernet/marvell/skge.c b/drivers/net/ethernet/marvell/skge.c
index 1b43704baceb..01d141369b3e 100644
--- a/drivers/net/ethernet/marvell/skge.c
+++ b/drivers/net/ethernet/marvell/skge.c
@@ -3776,7 +3776,7 @@ static __init void skge_debug_init(void)
 	register_netdevice_notifier(&skge_notifier);
 }
 
-static __exit void skge_debug_cleanup(void)
+static void skge_debug_cleanup(void)
 {
 	if (skge_debug) {
 		unregister_netdevice_notifier(&skge_notifier);
@@ -4179,10 +4179,16 @@ static const struct dmi_system_id skge_32bit_dma_boards[] = {
 
 static int __init skge_init_module(void)
 {
+	int ret;
+
 	if (dmi_check_system(skge_32bit_dma_boards))
 		only_32bit_dma = 1;
 	skge_debug_init();
-	return pci_register_driver(&skge_driver);
+	ret = pci_register_driver(&skge_driver);
+	if (ret)
+		skge_debug_cleanup();
+
+	return ret;
 }
 
 static void __exit skge_cleanup_module(void)
-- 
2.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ