x86, pci, mrst: Add extra sanity check in walking the PCI extended cap chain
[sfrench/cifs-2.6.git] / arch / x86 / pci / mrst.c
index 7ef3a2735df39f2fdfbd4624a440e22d3e169879..cb29191cee5877824391a33de0cea9c5255f2c55 100644 (file)
@@ -66,8 +66,9 @@ static int fixed_bar_cap(struct pci_bus *bus, unsigned int devfn)
                                          devfn, pos, 4, &pcie_cap))
                        return 0;
 
-               if (pcie_cap == 0xffffffff)
-                       return 0;
+               if (PCI_EXT_CAP_ID(pcie_cap) == 0x0000 ||
+                       PCI_EXT_CAP_ID(pcie_cap) == 0xffff)
+                       break;
 
                if (PCI_EXT_CAP_ID(pcie_cap) == PCI_EXT_CAP_ID_VNDR) {
                        raw_pci_ext_ops->read(pci_domain_nr(bus), bus->number,
@@ -76,7 +77,7 @@ static int fixed_bar_cap(struct pci_bus *bus, unsigned int devfn)
                                return pos;
                }
 
-               pos = pcie_cap >> 20;
+               pos = PCI_EXT_CAP_NEXT(pcie_cap);
        }
 
        return 0;