Commit 18da4340 authored by Alex Deucher's avatar Alex Deucher

drm/amdgpu: Do not directly dereference pointers to BIOS area.

Use readb() and memcpy_fromio() accessors instead.

Ported from radeon commit:
f2c9e560Acked-by: default avatarChristian König <christian.koenig@amd.com>
Acked-by: default avatarJammy Zhou <Jammy.Zhou@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 17b10f94
...@@ -75,7 +75,7 @@ static bool igp_read_bios_from_vram(struct amdgpu_device *adev) ...@@ -75,7 +75,7 @@ static bool igp_read_bios_from_vram(struct amdgpu_device *adev)
bool amdgpu_read_bios(struct amdgpu_device *adev) bool amdgpu_read_bios(struct amdgpu_device *adev)
{ {
uint8_t __iomem *bios; uint8_t __iomem *bios, val1, val2;
size_t size; size_t size;
adev->bios = NULL; adev->bios = NULL;
...@@ -85,15 +85,19 @@ bool amdgpu_read_bios(struct amdgpu_device *adev) ...@@ -85,15 +85,19 @@ bool amdgpu_read_bios(struct amdgpu_device *adev)
return false; return false;
} }
if (size == 0 || bios[0] != 0x55 || bios[1] != 0xaa) { val1 = readb(&bios[0]);
val2 = readb(&bios[1]);
if (size == 0 || val1 != 0x55 || val2 != 0xaa) {
pci_unmap_rom(adev->pdev, bios); pci_unmap_rom(adev->pdev, bios);
return false; return false;
} }
adev->bios = kmemdup(bios, size, GFP_KERNEL); adev->bios = kzalloc(size, GFP_KERNEL);
if (adev->bios == NULL) { if (adev->bios == NULL) {
pci_unmap_rom(adev->pdev, bios); pci_unmap_rom(adev->pdev, bios);
return false; return false;
} }
memcpy_fromio(adev->bios, bios, size);
pci_unmap_rom(adev->pdev, bios); pci_unmap_rom(adev->pdev, bios);
return true; return true;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment