diff options
-rw-r--r-- | drivers/pci/rom.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/pci/rom.c b/drivers/pci/rom.c index 838575e3fac6..713c78f3a65d 100644 --- a/drivers/pci/rom.c +++ b/drivers/pci/rom.c @@ -125,7 +125,9 @@ void __iomem *pci_map_rom(struct pci_dev *pdev, size_t *size) image += readw(pds + 16) * 512; } while (!last_image); - *size = image - rom; + /* never return a size larger than the PCI resource window */ + /* there are known ROMs that get the size wrong */ + *size = min((size_t)(image - rom), *size); return rom; } |