|
@@ -71,6 +71,7 @@ size_t pci_get_rom_size(struct pci_dev *pdev, void __iomem *rom, size_t size)
|
|
|
{
|
|
|
void __iomem *image;
|
|
|
int last_image;
|
|
|
+ unsigned length;
|
|
|
|
|
|
image = rom;
|
|
|
do {
|
|
@@ -93,9 +94,9 @@ size_t pci_get_rom_size(struct pci_dev *pdev, void __iomem *rom, size_t size)
|
|
|
if (readb(pds + 3) != 'R')
|
|
|
break;
|
|
|
last_image = readb(pds + 21) & 0x80;
|
|
|
- /* this length is reliable */
|
|
|
- image += readw(pds + 16) * 512;
|
|
|
- } while (!last_image);
|
|
|
+ length = readw(pds + 16);
|
|
|
+ image += length * 512;
|
|
|
+ } while (length && !last_image);
|
|
|
|
|
|
/* never return a size larger than the PCI resource window */
|
|
|
/* there are known ROMs that get the size wrong */
|