PCI: Add check code for last image indicator not set
authorRex Zhu <Rex.Zhu@amd.com>
Tue, 5 Jun 2018 01:46:46 +0000 (09:46 +0800)
committerBjorn Helgaas <bhelgaas@google.com>
Sat, 30 Jun 2018 02:16:23 +0000 (21:16 -0500)
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 <Rex.Zhu@amd.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
drivers/pci/rom.c

index 946795fc007187ee21643a324c1e88aab0f23e31..3a33f5ce314a83be9f9df5f26661d37046c22673 100644 (file)
@@ -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 */