diff mbox series

PCI: cpqphp: Fix error handling in cpqhpc_init()

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

Commit Message

Yuan Can Oct. 22, 2024, 9:29 a.m. UTC
The cpqhpc_init() returns without checking the retval from
pci_register_driver().
If the pci_register_driver() failed, the module failed to install,
leaving the cpqhp debugfs not unregistered.

Fixes: 9f3f4681291f ("[PATCH] PCI Hotplug: fix up the sysfs file in the compaq pci hotplug driver")
Signed-off-by: Yuan Can <yuancan@huawei.com>
---
 drivers/pci/hotplug/cpqphp_core.c | 4 ++++
 1 file changed, 4 insertions(+)
diff mbox series

Patch

diff --git a/drivers/pci/hotplug/cpqphp_core.c b/drivers/pci/hotplug/cpqphp_core.c
index 47a3ed16159a..933392fab8a3 100644
--- a/drivers/pci/hotplug/cpqphp_core.c
+++ b/drivers/pci/hotplug/cpqphp_core.c
@@ -1390,6 +1390,10 @@  static int __init cpqhpc_init(void)
 	cpqhp_initialize_debugfs();
 	result = pci_register_driver(&cpqhpc_driver);
 	dbg("pci_register_driver = %d\n", result);
+
+	if (result)
+		cpqhp_shutdown_debugfs();
+
 	return result;
 }