summaryrefslogtreecommitdiff
path: root/drivers/pci/rom.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/pci/rom.c')
-rw-r--r--drivers/pci/rom.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/pci/rom.c b/drivers/pci/rom.c
index 0decf0d81cf5..1f5e6af96c83 100644
--- a/drivers/pci/rom.c
+++ b/drivers/pci/rom.c
@@ -156,8 +156,13 @@ void __iomem *pci_map_rom(struct pci_dev *pdev, size_t *size)
* True size is important if the ROM is going to be copied.
*/
*size = pci_get_rom_size(pdev, rom, *size);
+ if (!*size)
+ goto invalid_rom;
+
return rom;
+invalid_rom:
+ iounmap(rom);
err_ioremap:
/* restore enable if ioremap fails */
if (!(res->flags & IORESOURCE_ROM_ENABLE))