Skip to contentSkip to conversation

i40e: Fix error handling in i40e_init_module()

PATCH In review Shang XiaoJing 3 participants 3 messages Nov 16, 2022 – Nov 22, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 i40e: Fix error handling in i40e_init_module()

i40e_init_module() won't free the debugfs directory created by i40e_dbg_init() when pci_register_driver() failed. Add fail path to call i40e_dbg_exit() to remove the debugfs entries to prevent the bug.

i40e: Intel(R) Ethernet Connection XL710 Network Driver
i40e: Copyright (c) 2013 - 2019 Intel Corporation.
debugfs: Directory 'i40e' with parent '/' already present!

Fixes 41c445ff0f48 ("i40e: main driver core")

---
changes in v2:
- destroy the workqueue in fail path too.

---
 drivers/net/ethernet/intel/i40e/i40e_main.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/i40e/i40e_main.c +10 -1
index b5dcd15ced36..b3cb587a2032 100644
@@ -16644,6 +16644,8 @@ static struct pci_driver i40e_driver = {
  **/
 static int __init i40e_init_module(void)
 {
+	int err;
+
 	pr_info("%s: %s\n", i40e_driver_name, i40e_driver_string);
 	pr_info("%s: %s\n", i40e_driver_name, i40e_copyright);
 
@@ -16661,7 +16663,14 @@ static int __init i40e_init_module(void)
 	}
 
 	i40e_dbg_init();
-	return pci_register_driver(&i40e_driver);
+	err = pci_register_driver(&i40e_driver);
+	if (err) {
+		destroy_workqueue(i40e_wq);
+		i40e_dbg_exit();
+		return err;
+	}
+
+	return 0;
 }
 module_init(i40e_init_module);
 
Signature · 1 line
2.17.1
Reviewed-by on v2 1/1
#1 lore raw
Quoted 8 lines · Shang XiaoJing

i40e_init_module() won't free the debugfs directory created by i40e_dbg_init() when pci_register_driver() failed. Add fail path to call i40e_dbg_exit() to remove the debugfs entries to prevent the bug.

i40e: Intel(R) Ethernet Connection XL710 Network Driver
i40e: Copyright (c) 2013 - 2019 Intel Corporation.
debugfs: Directory 'i40e' with parent '/' already present!

Quoted 9 lines
Fixes 41c445ff0f48 ("i40e: main driver core")

---
changes in v2:
- destroy the workqueue in fail path too.

---
 drivers/net/ethernet/intel/i40e/i40e_main.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

The subject line should indicate the target branch and needs to be [PATCH net v2] ....

Thanks,

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

Tested-by on v2 1/1
#2 lore raw
In reply to Shang XiaoJing
Quoted 23 lines

-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Shang XiaoJing
Sent: Wednesday, November 16, 2022 6:57 AM
To: Brandeburg, Jesse <[email protected]>; Nguyen, Anthony L <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; intel-wired- [email protected]; [email protected]
Cc: [email protected]
Subject: [Intel-wired-lan] [PATCH v2] i40e: Fix error handling in i40e_init_module()

i40e_init_module() won't free the debugfs directory created by i40e_dbg_init() when pci_register_driver() failed. Add fail path to call i40e_dbg_exit() to remove the debugfs entries to prevent the bug.

i40e: Intel(R) Ethernet Connection XL710 Network Driver
i40e: Copyright (c) 2013 - 2019 Intel Corporation.
debugfs: Directory 'i40e' with parent '/' already present!

Quoted 9 lines
Fixes 41c445ff0f48 ("i40e: main driver core")

---
changes in v2:
- destroy the workqueue in fail path too.

---
 drivers/net/ethernet/intel/i40e/i40e_main.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan