From: Jiang Liu <liuj97@gmail.com>
To: Yinghai Lu <yinghai@kernel.org>,
Jesse Barnes <jbarnes@virtuousgeek.org>,
Bjorn Helgaas <bhelgaas@google.com>
Cc: Jiang Liu <jiang.liu@huawei.com>, Ashok Raj <ashok.raj@intel.com>,
Suresh Siddha <suresh.b.siddha@intel.com>,
Youquan Song <youquan.song@intel.com>,
linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
chenkeping@huawei.com
Subject: [PATCH 2/5] Correctly clean up pci root buses in function pci_remove_bus()
Date: Mon, 12 Mar 2012 01:48:26 +0800 [thread overview]
Message-ID: <1331488109-13466-3-git-send-email-jiang.liu@huawei.com> (raw)
In-Reply-To: <1331488109-13466-1-git-send-email-jiang.liu@huawei.com>
The function pci_create_root_bus() allocates the pci bus structure,
registers the bus device and creates the legacy files for a pci root
bus, but returns without setting the is_added flag. The is_added flag
for a pci root bus will be set by function pci_scan_child_bus().
If a pci root bus is destroyed before calling pci_scan_child_bus(),
the is_added flag will not be set. So teach function pci_remove_bus()
to detect such a case and correctly clean up pci root buses.
Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
---
drivers/pci/remove.c | 9 ++++-----
1 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/drivers/pci/remove.c b/drivers/pci/remove.c
index 9ffc071..75b0092 100644
--- a/drivers/pci/remove.c
+++ b/drivers/pci/remove.c
@@ -70,11 +70,10 @@ void pci_remove_bus(struct pci_bus *pci_bus)
list_del(&pci_bus->node);
pci_bus_release_busn_res(pci_bus);
up_write(&pci_bus_sem);
- if (!pci_bus->is_added)
- return;
-
- pci_remove_legacy_files(pci_bus);
- device_unregister(&pci_bus->dev);
+ if (pci_bus->is_added || pci_is_root_bus(pci_bus)) {
+ pci_remove_legacy_files(pci_bus);
+ device_unregister(&pci_bus->dev);
+ }
}
EXPORT_SYMBOL(pci_remove_bus);
--
1.7.5.4
next prev parent reply other threads:[~2012-03-11 17:53 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-11 17:48 [RFC PATCH 0/5] PCI: introduce hotplug safe bus searching interfaces Jiang Liu
2012-03-11 17:48 ` [PATCH 1/5] Fix device reference count leakage in pci_dev_present() Jiang Liu
2012-03-11 17:48 ` Jiang Liu [this message]
2012-03-13 6:24 ` [PATCH 2/5] Correctly clean up pci root buses in function pci_remove_bus() Yinghai Lu
2012-03-13 7:23 ` Jiang Liu
2012-03-11 17:48 ` [PATCH 3/5] Fix an access-after-free issue in function pci_stop_and_remove_bus() Jiang Liu
2012-03-13 3:47 ` Bjorn Helgaas
2012-03-11 17:48 ` [RFC PATCH 4/5] PCI: Introduce hotplug-safe pci bus searching interfaces Jiang Liu
2012-03-13 3:49 ` Bjorn Helgaas
2012-03-13 8:13 ` Jiang Liu
2012-03-11 17:48 ` [RFC PATCH 5/5] PCI: Replace old pci bus searching function calls with hotplug safe ones Jiang Liu
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=1331488109-13466-3-git-send-email-jiang.liu@huawei.com \
--to=liuj97@gmail.com \
--cc=ashok.raj@intel.com \
--cc=bhelgaas@google.com \
--cc=chenkeping@huawei.com \
--cc=jbarnes@virtuousgeek.org \
--cc=jiang.liu@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=suresh.b.siddha@intel.com \
--cc=yinghai@kernel.org \
--cc=youquan.song@intel.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;
as well as URLs for NNTP newsgroup(s).