drm/nouveau/bios: fix a potential NULL deref in the PROM shadowing function
authorMartin Peres <martin.peres@free.fr>
Thu, 3 Apr 2014 20:12:41 +0000 (22:12 +0200)
committerBen Skeggs <bskeggs@redhat.com>
Tue, 10 Jun 2014 06:05:51 +0000 (16:05 +1000)
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Martin Peres <martin.peres@free.fr>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
drivers/gpu/drm/nouveau/core/subdev/bios/base.c

index 222e8eb..d45704a 100644 (file)
@@ -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);