From: Rajesh Shah With root bridge and pci bridge hot-plug, new buses and devices can be added or removed at run time. Protect the pci bus and device lists with the pci lock when doing so. Signed-off-by: Rajesh Shah Signed-off-by: Andrew Morton --- drivers/pci/probe.c | 11 ++++++++++- 1 files changed, 10 insertions(+), 1 deletion(-) diff -puN drivers/pci/probe.c~acpi-bridge-hotadd-take-the-pci-lock-when-modifying-pci-bus-or-device-lists drivers/pci/probe.c --- 25/drivers/pci/probe.c~acpi-bridge-hotadd-take-the-pci-lock-when-modifying-pci-bus-or-device-lists 2005-04-28 00:24:29.745356496 -0700 +++ 25-akpm/drivers/pci/probe.c 2005-04-28 00:24:29.750355736 -0700 @@ -370,8 +370,11 @@ struct pci_bus * __devinit pci_add_new_b struct pci_bus *child; child = pci_alloc_child_bus(parent, dev, busnr); - if (child) + if (child) { + spin_lock(&pci_bus_lock); list_add_tail(&child->node, &parent->children); + spin_unlock(&pci_bus_lock); + } return child; } @@ -761,7 +764,9 @@ pci_scan_single_device(struct pci_bus *b * and the bus list for fixup functions, etc. */ INIT_LIST_HEAD(&dev->global_list); + spin_lock(&pci_bus_lock); list_add_tail(&dev->bus_list, &bus->devices); + spin_unlock(&pci_bus_lock); return dev; } @@ -882,7 +887,9 @@ struct pci_bus * __devinit pci_scan_bus_ pr_debug("PCI: Bus %04x:%02x already known\n", pci_domain_nr(b), bus); goto err_out; } + spin_lock(&pci_bus_lock); list_add_tail(&b->node, &pci_root_buses); + spin_unlock(&pci_bus_lock); memset(dev, 0, sizeof(*dev)); dev->parent = parent; @@ -924,7 +931,9 @@ class_dev_create_file_err: class_dev_reg_err: device_unregister(dev); dev_reg_err: + spin_lock(&pci_bus_lock); list_del(&b->node); + spin_unlock(&pci_bus_lock); err_out: kfree(dev); kfree(b); _