forked from luck/tmp_suning_uos_patched
PCI: Fix infinite loop with ROM image of size 0
If the image size would ever read as 0, pci_get_rom_size() could keep processing the same image over and over again. Exit the loop if we ever read a length of zero. This fixes a soft lockup on boot when the radeon driver calls pci_get_rom_size() on an AMD Radeon R7 250X PCIe discrete graphics card. [bhelgaas: changelog, reference] Link: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1386973 Reported-by: Federico <federicotg@gmail.com> Signed-off-by: Michel Dänzer <michel.daenzer@amd.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Reviewed-by: Alex Deucher <alexander.deucher@amd.com> CC: stable@vger.kernel.org
This commit is contained in:
parent
97bf6af1f9
commit
16b036af31
|
@ -71,6 +71,7 @@ size_t pci_get_rom_size(struct pci_dev *pdev, void __iomem *rom, size_t size)
|
||||||
{
|
{
|
||||||
void __iomem *image;
|
void __iomem *image;
|
||||||
int last_image;
|
int last_image;
|
||||||
|
unsigned length;
|
||||||
|
|
||||||
image = rom;
|
image = rom;
|
||||||
do {
|
do {
|
||||||
|
@ -93,9 +94,9 @@ size_t pci_get_rom_size(struct pci_dev *pdev, void __iomem *rom, size_t size)
|
||||||
if (readb(pds + 3) != 'R')
|
if (readb(pds + 3) != 'R')
|
||||||
break;
|
break;
|
||||||
last_image = readb(pds + 21) & 0x80;
|
last_image = readb(pds + 21) & 0x80;
|
||||||
/* this length is reliable */
|
length = readw(pds + 16);
|
||||||
image += readw(pds + 16) * 512;
|
image += length * 512;
|
||||||
} while (!last_image);
|
} while (length && !last_image);
|
||||||
|
|
||||||
/* never return a size larger than the PCI resource window */
|
/* never return a size larger than the PCI resource window */
|
||||||
/* there are known ROMs that get the size wrong */
|
/* there are known ROMs that get the size wrong */
|
||||||
|
|
Loading…
Reference in New Issue
Block a user