diff options
author | Changbin Du <changbin.du@intel.com> | 2017-11-07 19:26:53 -0500 |
---|---|---|
committer | Bjorn Helgaas <bhelgaas@google.com> | 2017-11-08 15:47:07 -0500 |
commit | a405f191f42ead45a03c000110a16683d30f7333 (patch) | |
tree | b215842a21055c1e8ccc854b3b5de7d6f8a4f84c | |
parent | a48a687d8cdf9a51a6283cc91f9637403b221ed3 (diff) |
PCI: Fail pci_map_rom() if the option ROM is invalid
If we detect a invalid PCI option ROM (e.g., invalid ROM header signature),
we should unmap it immediately and fail. It doesn't make any sense to
return a mapped area with size of 0.
I have seen this case on Intel GVTg vGPU, which has no VBIOS. It will not
cause a real problem, but we should skip it as early as possible.
Signed-off-by: Changbin Du <changbin.du@intel.com>
[bhelgaas: split non-functional change into separate patch]
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
-rw-r--r-- | drivers/pci/rom.c | 5 |
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) | |||
156 | * True size is important if the ROM is going to be copied. | 156 | * True size is important if the ROM is going to be copied. |
157 | */ | 157 | */ |
158 | *size = pci_get_rom_size(pdev, rom, *size); | 158 | *size = pci_get_rom_size(pdev, rom, *size); |
159 | if (!*size) | ||
160 | goto invalid_rom; | ||
161 | |||
159 | return rom; | 162 | return rom; |
160 | 163 | ||
164 | invalid_rom: | ||
165 | iounmap(rom); | ||
161 | err_ioremap: | 166 | err_ioremap: |
162 | /* restore enable if ioremap fails */ | 167 | /* restore enable if ioremap fails */ |
163 | if (!(res->flags & IORESOURCE_ROM_ENABLE)) | 168 | if (!(res->flags & IORESOURCE_ROM_ENABLE)) |