From: Martin Peres Date: Thu, 3 Apr 2014 20:12:41 +0000 (+0200) Subject: drm/nouveau/bios: fix a potential NULL deref in the PROM shadowing function X-Git-Tag: v4.9.8~6258^2~2^2~11 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=29ba8c8abf9729b0091eccf9f7044f6940d789d0;p=platform%2Fkernel%2Flinux-rpi3.git 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 --- diff --git a/drivers/gpu/drm/nouveau/core/subdev/bios/base.c b/drivers/gpu/drm/nouveau/core/subdev/bios/base.c index 222e8eb..d45704a 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);