PCI: acpiphp: Use list_for_each_entry_safe() in acpiphp_sanitize_bus()
authorYijing Wang <wangyijing@huawei.com>
Fri, 12 Apr 2013 05:44:17 +0000 (05:44 +0000)
committerBjorn Helgaas <bhelgaas@google.com>
Fri, 12 Apr 2013 21:38:25 +0000 (15:38 -0600)
Function acpiphp_sanitize_bus() may call pci_stop_and_remove_bus_device(),
which in turn may remove device from bus->devices list. So walk the
bus->devices list with list_for_each_entry_safe().

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Yinghai Lu <yinghai@kernel.org>
Cc: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
Cc: Toshi Kani <toshi.kani@hp.com>
drivers/pci/hotplug/acpiphp_glue.c

index 270fdbadc19c93e97b62db8049a1542a748b1223..7948bc9196055827bae4b10b1225f936ba1d93b7 100644 (file)
@@ -1082,11 +1082,11 @@ static void acpiphp_set_hpp_values(struct pci_bus *bus)
  */
 static void acpiphp_sanitize_bus(struct pci_bus *bus)
 {
-       struct pci_dev *dev;
+       struct pci_dev *dev, *tmp;
        int i;
        unsigned long type_mask = IORESOURCE_IO | IORESOURCE_MEM;
 
-       list_for_each_entry(dev, &bus->devices, bus_list) {
+       list_for_each_entry_safe(dev, tmp, &bus->devices, bus_list) {
                for (i=0; i<PCI_BRIDGE_RESOURCES; i++) {
                        struct resource *res = &dev->resource[i];
                        if ((res->flags & type_mask) && !res->start &&