diff options
author | Alex Deucher <alexander.deucher@amd.com> | 2015-04-17 10:50:02 -0400 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2015-06-03 21:03:16 -0400 |
commit | 18da4340e651dd41d698fc54084b9139b614539b (patch) | |
tree | 3113353e0f9706dcfd2d8547b1dcb9304e7ac609 /drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c | |
parent | 17b10f941f939da459072a066c6e5e9af9dda610 (diff) |
drm/amdgpu: Do not directly dereference pointers to BIOS area.
Use readb() and memcpy_fromio() accessors instead.
Ported from radeon commit:
f2c9e560b406f2f6b14b345c7da33467dee9cdf2
Acked-by: Christian König <christian.koenig@amd.com>
Acked-by: Jammy Zhou <Jammy.Zhou@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c')
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c index d7a3ab2624f0..ceb444f6d418 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c | |||
@@ -75,7 +75,7 @@ static bool igp_read_bios_from_vram(struct amdgpu_device *adev) | |||
75 | 75 | ||
76 | bool amdgpu_read_bios(struct amdgpu_device *adev) | 76 | bool amdgpu_read_bios(struct amdgpu_device *adev) |
77 | { | 77 | { |
78 | uint8_t __iomem *bios; | 78 | uint8_t __iomem *bios, val1, val2; |
79 | size_t size; | 79 | size_t size; |
80 | 80 | ||
81 | adev->bios = NULL; | 81 | adev->bios = NULL; |
@@ -85,15 +85,19 @@ bool amdgpu_read_bios(struct amdgpu_device *adev) | |||
85 | return false; | 85 | return false; |
86 | } | 86 | } |
87 | 87 | ||
88 | if (size == 0 || bios[0] != 0x55 || bios[1] != 0xaa) { | 88 | val1 = readb(&bios[0]); |
89 | val2 = readb(&bios[1]); | ||
90 | |||
91 | if (size == 0 || val1 != 0x55 || val2 != 0xaa) { | ||
89 | pci_unmap_rom(adev->pdev, bios); | 92 | pci_unmap_rom(adev->pdev, bios); |
90 | return false; | 93 | return false; |
91 | } | 94 | } |
92 | adev->bios = kmemdup(bios, size, GFP_KERNEL); | 95 | adev->bios = kzalloc(size, GFP_KERNEL); |
93 | if (adev->bios == NULL) { | 96 | if (adev->bios == NULL) { |
94 | pci_unmap_rom(adev->pdev, bios); | 97 | pci_unmap_rom(adev->pdev, bios); |
95 | return false; | 98 | return false; |
96 | } | 99 | } |
100 | memcpy_fromio(adev->bios, bios, size); | ||
97 | pci_unmap_rom(adev->pdev, bios); | 101 | pci_unmap_rom(adev->pdev, bios); |
98 | return true; | 102 | return true; |
99 | } | 103 | } |