From 29ba8c8abf9729b0091eccf9f7044f6940d789d0 Mon Sep 17 00:00:00 2001 From: Martin Peres Date: Thu, 3 Apr 2014 22:12:41 +0200 Subject: [PATCH] drm/nouveau/bios: fix a potential NULL deref in the PROM shadowing function Reported-by: Dan Carpenter Signed-off-by: Martin Peres Signed-off-by: Ben Skeggs --- drivers/gpu/drm/nouveau/core/subdev/bios/base.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/nouveau/core/subdev/bios/base.c b/drivers/gpu/drm/nouveau/core/subdev/bios/base.c index 222e8ebb669d..d45704a2c2df 100644 --- a/drivers/gpu/drm/nouveau/core/subdev/bios/base.c +++ b/drivers/gpu/drm/nouveau/core/subdev/bios/base.c @@ -183,10 +183,11 @@ nouveau_bios_shadow_prom(struct nouveau_bios *bios) goto out; bios->data = kmalloc(bios->size, GFP_KERNEL); - if (bios->data) { - for (i = 0; i < bios->size; i += 4) - ((u32 *)bios->data)[i/4] = nv_rd32(bios, 0x300000 + i); - } + if (!bios->data) + goto out; + + for (i = 0; i < bios->size; i += 4) + ((u32 *)bios->data)[i/4] = nv_rd32(bios, 0x300000 + i); /* check the PCI record header */ pcir = nv_ro16(bios, 0x0018); -- 2.39.5