From beced88e6af43c9653cee09f5111ae7495824e07 Mon Sep 17 00:00:00 2001 From: Rex Zhu Date: Tue, 5 Jun 2018 09:46:46 +0800 Subject: PCI: Add check code for last image indicator not set If the "last image" indicator was not set in the PCI data struct, print "No more image in the PCI ROM" instead of looping back and printing "Invalid PCI ROM header signature". Signed-off-by: Rex Zhu Signed-off-by: Bjorn Helgaas Reviewed-by: Alex Deucher --- drivers/pci/rom.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'drivers/pci/rom.c') diff --git a/drivers/pci/rom.c b/drivers/pci/rom.c index 946795fc0071..3a33f5ce314a 100644 --- a/drivers/pci/rom.c +++ b/drivers/pci/rom.c @@ -108,6 +108,12 @@ size_t pci_get_rom_size(struct pci_dev *pdev, void __iomem *rom, size_t size) /* Avoid iterating through memory outside the resource window */ if (image >= rom + size) break; + if (!last_image) { + if (readw(image) != 0xAA55) { + pci_info(pdev, "No more image in the PCI ROM\n"); + break; + } + } } while (length && !last_image); /* never return a size larger than the PCI resource window */ -- cgit v1.2.3-59-g8ed1b