]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
PCI: Avoid accessing memory outside the ROM BAR
authorRex Zhu <Rex.Zhu@amd.com>
Tue, 5 Jun 2018 01:46:45 +0000 (09:46 +0800)
committerBjorn Helgaas <bhelgaas@google.com>
Sat, 30 Jun 2018 02:07:17 +0000 (21:07 -0500)
pci_get_rom_size() accepts the base and size of the ROM BAR as arguments.
The byte at "rom + size" is the first byte *past* the ROM, so change ">" to
">=" to avoid accessing beyond the actual length of the ROM BAR.

Signed-off-by: Rex Zhu <Rex.Zhu@amd.com>
[bhelgaas: changelog]
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
drivers/pci/rom.c

index a7b5c37a85ec3d793d3b67d54db42bab03be828f..946795fc007187ee21643a324c1e88aab0f23e31 100644 (file)
@@ -106,7 +106,7 @@ size_t pci_get_rom_size(struct pci_dev *pdev, void __iomem *rom, size_t size)
                length = readw(pds + 16);
                image += length * 512;
                /* Avoid iterating through memory outside the resource window */
-               if (image > rom + size)
+               if (image >= rom + size)
                        break;
        } while (length && !last_image);