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 222e8ebb669dff496534331682e7a77c7e6bd9e0..d45704a2c2df5b6aa1b95eda83d990995955e4c5 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);