Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

radeon: Do not directly dereference pointers to BIOS area.

Use readb() and memcpy_fromio() accessors instead.

Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Cc: stable@vger.kernel.org

authored by

David Miller and committed by
Alex Deucher
f2c9e560 3899ca84

+7 -3
+7 -3
drivers/gpu/drm/radeon/radeon_bios.c
··· 76 76 77 77 static bool radeon_read_bios(struct radeon_device *rdev) 78 78 { 79 - uint8_t __iomem *bios; 79 + uint8_t __iomem *bios, val1, val2; 80 80 size_t size; 81 81 82 82 rdev->bios = NULL; ··· 86 86 return false; 87 87 } 88 88 89 - if (size == 0 || bios[0] != 0x55 || bios[1] != 0xaa) { 89 + val1 = readb(&bios[0]); 90 + val2 = readb(&bios[1]); 91 + 92 + if (size == 0 || val1 != 0x55 || val2 != 0xaa) { 90 93 pci_unmap_rom(rdev->pdev, bios); 91 94 return false; 92 95 } 93 - rdev->bios = kmemdup(bios, size, GFP_KERNEL); 96 + rdev->bios = kzalloc(size, GFP_KERNEL); 94 97 if (rdev->bios == NULL) { 95 98 pci_unmap_rom(rdev->pdev, bios); 96 99 return false; 97 100 } 101 + memcpy_fromio(rdev->bios, bios, size); 98 102 pci_unmap_rom(rdev->pdev, bios); 99 103 return true; 100 104 }