Skip to content

Commit f2c9e56

Browse files
davem330alexdeucher
authored andcommitted
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
1 parent 3899ca8 commit f2c9e56

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

‎drivers/gpu/drm/radeon/radeon_bios.c‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ static bool igp_read_bios_from_vram(struct radeon_device *rdev)
7676

7777
static bool radeon_read_bios(struct radeon_device *rdev)
7878
{
79-
uint8_t __iomem *bios;
79+
uint8_t __iomem *bios, val1, val2;
8080
size_t size;
8181

8282
rdev->bios = NULL;
@@ -86,15 +86,19 @@ static bool radeon_read_bios(struct radeon_device *rdev)
8686
return false;
8787
}
8888

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) {
9093
pci_unmap_rom(rdev->pdev, bios);
9194
return false;
9295
}
93-
rdev->bios = kmemdup(bios, size, GFP_KERNEL);
96+
rdev->bios = kzalloc(size, GFP_KERNEL);
9497
if (rdev->bios == NULL) {
9598
pci_unmap_rom(rdev->pdev, bios);
9699
return false;
97100
}
101+
memcpy_fromio(rdev->bios, bios, size);
98102
pci_unmap_rom(rdev->pdev, bios);
99103
return true;
100104
}

0 commit comments

Comments
 (0)