PCI: Increment max correctly in pci_scan_bridge()
authorAndreas Noever <andreas.noever@gmail.com>
Thu, 23 Jan 2014 20:59:21 +0000 (21:59 +0100)
committerBjorn Helgaas <bhelgaas@google.com>
Mon, 10 Feb 2014 23:50:49 +0000 (16:50 -0700)
This patch fixes two small issues:
 - If pci_add_new_bus() fails, max must not be incremented. Otherwise
   an incorrect value is returned from pci_scan_bridge().
 - If the bus is already present, max must be incremented. I think
   that this case should only be hit if we trigger a manual rescan of a
   CardBus bridge.

Signed-off-by: Andreas Noever <andreas.noever@gmail.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
drivers/pci/probe.c

index 6e34498ec9f0269387c296e498174ccb29cbe3fb..f340c947d8cbe2bc1714d2534f00558f515084bc 100644 (file)
@@ -852,11 +852,12 @@ int pci_scan_bridge(struct pci_bus *bus, struct pci_dev *dev, int max, int pass)
                 * this case we only re-scan this bus. */
                child = pci_find_bus(pci_domain_nr(bus), max+1);
                if (!child) {
-                       child = pci_add_new_bus(bus, dev, ++max);
+                       child = pci_add_new_bus(bus, dev, max+1);
                        if (!child)
                                goto out;
-                       pci_bus_insert_busn_res(child, max, 0xff);
+                       pci_bus_insert_busn_res(child, max+1, 0xff);
                }
+               max++;
                buses = (buses & 0xff000000)
                      | ((unsigned int)(child->primary)     <<  0)
                      | ((unsigned int)(child->busn_res.start)   <<  8)
This page took 0.02612 seconds and 5 git commands to generate.