linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] radeon: Do not directly dereference pointers to BIOS area.
@ 2015-03-19  3:18 David Miller
  2015-03-19  8:50 ` Christian König
  0 siblings, 1 reply; 7+ messages in thread
From: David Miller @ 2015-03-19  3:18 UTC (permalink / raw)
  To: alexander.deucher; +Cc: christian.koenig, dri-devel, linux-kernel


Use readb() and memcpy_fromio() accessors instead.

Signed-off-by: David S. Miller <davem@davemloft.net>

diff --git a/drivers/gpu/drm/radeon/radeon_bios.c b/drivers/gpu/drm/radeon/radeon_bios.c
index 63ccb8f..d27e4cc 100644
--- a/drivers/gpu/drm/radeon/radeon_bios.c
+++ b/drivers/gpu/drm/radeon/radeon_bios.c
@@ -76,7 +76,7 @@ static bool igp_read_bios_from_vram(struct radeon_device *rdev)
 
 static bool radeon_read_bios(struct radeon_device *rdev)
 {
-	uint8_t __iomem *bios;
+	uint8_t __iomem *bios, val1, val2;
 	size_t size;
 
 	rdev->bios = NULL;
@@ -86,15 +86,19 @@ static bool radeon_read_bios(struct radeon_device *rdev)
 		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(rdev->pdev, bios);
 		return false;
 	}
-	rdev->bios = kmemdup(bios, size, GFP_KERNEL);
+	rdev->bios = kzalloc(size, GFP_KERNEL);
 	if (rdev->bios == NULL) {
 		pci_unmap_rom(rdev->pdev, bios);
 		return false;
 	}
+	memcpy_fromio(rdev->bios, bios, size);
 	pci_unmap_rom(rdev->pdev, bios);
 	return true;
 }

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-03-20 17:39 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-19  3:18 [PATCH] radeon: Do not directly dereference pointers to BIOS area David Miller
2015-03-19  8:50 ` Christian König
2015-03-19 16:29   ` David Miller
2015-03-20  9:38     ` Christian König
2015-03-20 13:50       ` Alex Deucher
2015-03-20 17:24       ` David Miller
2015-03-20 17:39         ` Deucher, Alexander

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).