From: Xiangwei Li <liwei728@huawei.com>
To: <make24@iscas.ac.cn>, <bhelgaas@google.com>
Cc: <linux-kernel@vger.kernel.org>, <linux-pci@vger.kernel.org>,
<liwei728@huawei.com>, <bobo.shaobowang@huawei.com>,
<wangxiongfeng2@huawei.com>
Subject: [PATCH] Revert "PCI: Fix reference leak in pci_register_host_bridge()"
Date: Thu, 10 Apr 2025 11:28:42 +0800 [thread overview]
Message-ID: <20250410032842.246396-1-liwei728@huawei.com> (raw)
This reverts commit 804443c1f27883926de94c849d91f5b7d7d696e9.
The newly added logic incorrectly sets bus_registered to true even when
device_register returns an error, this is incorrect.
When device_register fails, there is no need to release the reference count,
and there are no direct error-handling operations following its execution.
Therefore, this patch is meaningless and should be reverted.
Fixes: 804443c1f278 ("PCI: Fix reference leak in pci_register_host_bridge()")
Signed-off-by: Xiangwei Li <liwei728@huawei.com>
Signed-off-by: Xiongfeng Wang <wangxiongfeng2@huawei.com>
---
drivers/pci/probe.c | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 364fa2a514f8..8595d41add09 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -957,7 +957,6 @@ static int pci_register_host_bridge(struct pci_host_bridge *bridge)
resource_size_t offset, next_offset;
LIST_HEAD(resources);
struct resource *res, *next_res;
- bool bus_registered = false;
char addr[64], *fmt;
const char *name;
int err;
@@ -1021,7 +1020,6 @@ static int pci_register_host_bridge(struct pci_host_bridge *bridge)
name = dev_name(&bus->dev);
err = device_register(&bus->dev);
- bus_registered = true;
if (err)
goto unregister;
@@ -1110,15 +1108,12 @@ static int pci_register_host_bridge(struct pci_host_bridge *bridge)
unregister:
put_device(&bridge->dev);
device_del(&bridge->dev);
+
free:
#ifdef CONFIG_PCI_DOMAINS_GENERIC
pci_bus_release_domain_nr(parent, bus->domain_nr);
#endif
- if (bus_registered)
- put_device(&bus->dev);
- else
- kfree(bus);
-
+ kfree(bus);
return err;
}
--
2.25.1
next reply other threads:[~2025-04-10 3:10 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-10 3:28 Xiangwei Li [this message]
2025-04-10 11:19 ` Su Hui
2025-04-12 3:18 ` liwei (JK)
2025-04-14 1:48 ` Su Hui
2025-04-14 2:41 ` liwei (JK)
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=20250410032842.246396-1-liwei728@huawei.com \
--to=liwei728@huawei.com \
--cc=bhelgaas@google.com \
--cc=bobo.shaobowang@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=make24@iscas.ac.cn \
--cc=wangxiongfeng2@huawei.com \
/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
all inboxes | Powered by JetHome®