Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 445ec321 authored by Rex Zhu's avatar Rex Zhu Committed by Bjorn Helgaas
Browse files

PCI: Avoid accessing memory outside the ROM BAR



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: default avatarRex Zhu <Rex.Zhu@amd.com>
[bhelgaas: changelog]
Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
Reviewed-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 11eb0e0e
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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);