From: Yuan Can <yuancan@huawei.com>
To: <bhelgaas@google.com>, <gregkh@suse.de>, <linux-pci@vger.kernel.org>
Cc: <yuancan@huawei.com>
Subject: [PATCH v2] PCI: cpqphp: Fix error handling in cpqhpc_init()
Date: Wed, 23 Nov 2022 09:40:50 +0000 [thread overview]
Message-ID: <20221123094050.11457-1-yuancan@huawei.com> (raw)
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 --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;
}
--
2.17.1
reply other threads:[~2022-11-23 9:45 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221123094050.11457-1-yuancan@huawei.com \
--to=yuancan@huawei.com \
--cc=bhelgaas@google.com \
--cc=gregkh@suse.de \
--cc=linux-pci@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).