Skip to content

Commit

Permalink
x86, pci, mrst: Add extra sanity check in walking the PCI extended ca…
Browse files Browse the repository at this point in the history
…p chain

The fixed bar capability structure is searched in PCI extended
configuration space.  We need to make sure there is a valid capability
ID to begin with otherwise, the search code may stuck in a infinite
loop which results in boot hang.  This patch adds additional check for
cap ID 0, which is also invalid, and indicates end of chain.

End of chain is supposed to have all fields zero, but that doesn't
seem to always be the case in the field.

Suggested-by: "H. Peter Anvin" <[email protected]>
Signed-off-by: Jacob Pan <[email protected]>
Reviewed-by: Jesse Barnes <[email protected]>
LKML-Reference: <[email protected]>
Signed-off-by: H. Peter Anvin <[email protected]>
  • Loading branch information
Jacob Pan authored and H. Peter Anvin committed Jul 16, 2010
1 parent fd19dce commit f82c3d7
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions arch/x86/pci/mrst.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;
Expand Down

0 comments on commit f82c3d7

Please sign in to comment.