drm/amdgpu: Do not directly dereference pointers to BIOS area.
authorAlex Deucher <alexander.deucher@amd.com>
Fri, 17 Apr 2015 14:50:02 +0000 (10:50 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 4 Jun 2015 01:03:16 +0000 (21:03 -0400)
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>
drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c

index d7a3ab2624f0caf2b3a586dfb6f1082c10de3c30..ceb444f6d418d44255d812a1b2345ed6eac4c9b1 100644 (file)
@@ -75,7 +75,7 @@ static bool igp_read_bios_from_vram(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;
 
        adev->bios = NULL;
@@ -85,15 +85,19 @@ bool amdgpu_read_bios(struct amdgpu_device *adev)
                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);
                return false;
        }
-       adev->bios = kmemdup(bios, size, GFP_KERNEL);
+       adev->bios = kzalloc(size, GFP_KERNEL);
        if (adev->bios == NULL) {
                pci_unmap_rom(adev->pdev, bios);
                return false;
        }
+       memcpy_fromio(adev->bios, bios, size);
        pci_unmap_rom(adev->pdev, bios);
        return true;
 }
This page took 0.031405 seconds and 5 git commands to generate.