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>
This commit is contained in:

committed by
Bjorn Helgaas

parent
6754676297
commit
017ffe64e8
@@ -126,7 +126,6 @@ struct pci_dev *of_create_pci_dev(struct device_node *node,
|
||||
{
|
||||
struct pci_dev *dev;
|
||||
const char *type;
|
||||
struct pci_slot *slot;
|
||||
|
||||
dev = pci_alloc_dev(bus);
|
||||
if (!dev)
|
||||
@@ -145,10 +144,7 @@ struct pci_dev *of_create_pci_dev(struct device_node *node,
|
||||
dev->needs_freset = 0; /* pcie fundamental reset required */
|
||||
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);
|
||||
dev->vendor = get_int_prop(node, "vendor-id", 0xffff);
|
||||
dev->device = get_int_prop(node, "device-id", 0xffff);
|
||||
dev->subsystem_vendor = get_int_prop(node, "subsystem-vendor-id", 0);
|
||||
|
Reference in New Issue
Block a user