diff options
author | Vladis Dronov <vdronov@redhat.com> | 2015-11-27 18:20:06 +0100 |
---|---|---|
committer | Bjorn Helgaas <bhelgaas@google.com> | 2015-12-10 19:38:06 -0600 |
commit | 4066df6345f5b3bacdf7944c4d9a839f1eef5773 (patch) | |
tree | 1d6eefb6bb0b8c0b6aad19d2ebd1ca59d2d9c6cd /drivers/pci/rom.c | |
parent | 93de6901766c6821538b74a092e47780a9120fac (diff) | |
download | op-kernel-dev-4066df6345f5b3bacdf7944c4d9a839f1eef5773.zip op-kernel-dev-4066df6345f5b3bacdf7944c4d9a839f1eef5773.tar.gz |
PCI: Print warnings for all invalid expansion ROM headers
We've always validated that both bytes of the Expansion ROM signature and
all four bytes of the PCI Data Structure signature (see PCI Firmware spec
r3.0, sec 5.1.1), but we only printed a warning if the first byte of the
ROM signature was invalid.
Print warnings if *any* of those bytes are invalid. Note that we only look
at these headers if we map or read the ROM.
[bhelgaas: changelog, tweak printk format]
Signed-off-by: Vladis Dronov <vdronov@redhat.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Diffstat (limited to 'drivers/pci/rom.c')
-rw-r--r-- | drivers/pci/rom.c | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/drivers/pci/rom.c b/drivers/pci/rom.c index eb0ad53..5a1a39d 100644 --- a/drivers/pci/rom.c +++ b/drivers/pci/rom.c @@ -77,22 +77,18 @@ size_t pci_get_rom_size(struct pci_dev *pdev, void __iomem *rom, size_t size) do { void __iomem *pds; /* Standard PCI ROMs start out with these bytes 55 AA */ - if (readb(image) != 0x55) { - dev_err(&pdev->dev, "Invalid ROM contents\n"); + if (readw(image) != 0xAA55) { + dev_err(&pdev->dev, "Invalid PCI ROM header signature: expecting 0xaa55, got %#06x\n", + readw(image)); break; } - if (readb(image + 1) != 0xAA) - break; - /* get the PCI data structure and check its signature */ + /* get the PCI data structure and check its "PCIR" signature */ pds = image + readw(image + 24); - if (readb(pds) != 'P') - break; - if (readb(pds + 1) != 'C') - break; - if (readb(pds + 2) != 'I') - break; - if (readb(pds + 3) != 'R') + if (readl(pds) != 0x52494350) { + dev_err(&pdev->dev, "Invalid PCI ROM data signature: expecting 0x52494350, got %#010x\n", + readl(pds)); break; + } last_image = readb(pds + 21) & 0x80; length = readw(pds + 16); image += length * 512; |