Linux PCI subsystem development
 help / color / mirror / Atom feed
* [PATCH] PCI: cpqphp: Fix error handling in cpqhpc_init()
@ 2022-11-22 10:13 Yuan Can
  2022-11-22 20:05 ` Bjorn Helgaas
  0 siblings, 1 reply; 4+ messages in thread
From: Yuan Can @ 2022-11-22 10:13 UTC (permalink / raw)
  To: bhelgaas, gregkh, linux-pci; +Cc: yuancan

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>
---
 drivers/pci/hotplug/cpqphp_core.c | 2 ++
 1 file changed, 2 insertions(+)

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


^ permalink raw reply related	[flat|nested] 4+ messages in thread
* [PATCH] PCI: cpqphp: Fix error handling in cpqhpc_init()
@ 2024-10-22  9:29 Yuan Can
  0 siblings, 0 replies; 4+ messages in thread
From: Yuan Can @ 2024-10-22  9:29 UTC (permalink / raw)
  To: bhelgaas, gregkh, linux-pci; +Cc: yuancan

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 --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;
 }
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-10-22  9:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-22 10:13 [PATCH] PCI: cpqphp: Fix error handling in cpqhpc_init() Yuan Can
2022-11-22 20:05 ` Bjorn Helgaas
2022-11-23  2:18   ` Yuan Can
  -- strict thread matches above, loose matches on Subject: below --
2024-10-22  9:29 Yuan Can

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox