aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/probe.c
diff options
context:
space:
mode:
authorYijing Wang <wangyijing@huawei.com>2015-07-17 17:16:32 +0800
committerBjorn Helgaas <bhelgaas@google.com>2015-07-30 16:19:53 -0500
commit017ffe64e8b8c8db0f50433a71da41c6a4e12710 (patch)
treee15b309ad6ebf5322bb3c2a54ba244750dd57c0b /drivers/pci/probe.c
parentPCI: Protect pci_bus->slots with pci_slot_mutex, not pci_bus_sem (diff)
downloadlinux-dev-017ffe64e8b8c8db0f50433a71da41c6a4e12710.tar.xz
linux-dev-017ffe64e8b8c8db0f50433a71da41c6a4e12710.zip
PCI: Hold pci_slot_mutex while searching bus->slots list
Previously, pci_setup_device() and similar functions searched the pci_bus->slots list without any locking. It was possible for another thread to update the list while we searched it. Add pci_dev_assign_slot() to search the list while holding pci_slot_mutex. [bhelgaas: changelog, fold in CONFIG_SYSFS fix] Tested-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Yijing Wang <wangyijing@huawei.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Diffstat (limited to 'drivers/pci/probe.c')
-rw-r--r--drivers/pci/probe.c6
1 files changed, 1 insertions, 5 deletions
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index cefd636681b6..2a9ce16cb374 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1133,7 +1133,6 @@ int pci_setup_device(struct pci_dev *dev)
{
u32 class;
u8 hdr_type;
- struct pci_slot *slot;
int pos = 0;
struct pci_bus_region region;
struct resource *res;
@@ -1149,10 +1148,7 @@ int pci_setup_device(struct pci_dev *dev)
dev->error_state = pci_channel_io_normal;
set_pcie_port_type(dev);
- list_for_each_entry(slot, &dev->bus->slots, list)
- if (PCI_SLOT(dev->devfn) == slot->number)
- dev->slot = slot;
-
+ pci_dev_assign_slot(dev);
/* Assume 32-bit PCI; let 64-bit PCI cards (which are far rarer)
set this higher, assuming the system even supports it. */
dev->dma_mask = 0xffffffff;