diff mbox series

[v2] PCI: cpqphp: Fix error handling in cpqhpc_init()

Message ID 20221123094050.11457-1-yuancan@huawei.com (mailing list archive)
State New, archived
Delegated to: Bjorn Helgaas
Headers show
Series [v2] PCI: cpqphp: Fix error handling in cpqhpc_init() | expand

Commit Message

Yuan Can Nov. 23, 2022, 9:40 a.m. UTC
The cpqhpc_init() returns the result of pci_register_driver() without
checking it, if pci_register_driver() failed, the debugfs created in
cpqhp_initialize_debugfs() is not removed, resulting the debugfs of
cpqhp can never be created later.

Fix by calling cpqhp_shutdown_debugfs() when pci_register_driver() failed.

Fixes: 9f3f4681291f ("[PATCH] PCI Hotplug: fix up the sysfs file in the compaq pci hotplug driver")
Signed-off-by: Yuan Can <yuancan@huawei.com>
---
Changes in v2:
- change commit message format
- change to the suggested way of error handling
 drivers/pci/hotplug/cpqphp_core.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/drivers/pci/hotplug/cpqphp_core.c b/drivers/pci/hotplug/cpqphp_core.c
index c94b40e64baf..928b141bbdc1 100644
--- a/drivers/pci/hotplug/cpqphp_core.c
+++ b/drivers/pci/hotplug/cpqphp_core.c
@@ -1387,8 +1387,11 @@  static int __init cpqhpc_init(void)
 	cpqhp_debug = debug;
 
 	info(DRIVER_DESC " version: " DRIVER_VERSION "\n");
-	cpqhp_initialize_debugfs();
 	result = pci_register_driver(&cpqhpc_driver);
+	if (result)
+		return result;
+
+	cpqhp_initialize_debugfs();
 	dbg("pci_register_driver = %d\n", result);
 	return result;
 }