drm/nouveau/bios: fetch the vbios from PROM using only aligned 32-bit accesses

Dan Carpenter dan.carpenter at oracle.com
Wed Apr 2 09:55:29 PDT 2014


Hello Martin Peres,

The patch 18acc6d84eba: "drm/nouveau/bios: fetch the vbios from PROM
using only aligned 32-bit accesses" from Mar 25, 2014, leads to the
following static checker warning:

	drivers/gpu/drm/nouveau/core/subdev/bios/base.c:191 nouveau_bios_shadow_prom()
	error: potential null dereference 'bios->data'. (kmalloc returns null)

drivers/gpu/drm/nouveau/core/subdev/bios/base.c
   178          /* read entire bios image to system memory */
   179          bios->size = ((nv_rd32(bios, 0x300000) >> 16) & 0xff) * 512;
   180          if (!bios->size)
   181                  goto out;
   182  
   183          bios->data = kmalloc(bios->size, GFP_KERNEL);
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Allocation.

   184          if (bios->data) {
   185                  for (i = 0; i < bios->size; i+=4)
   186                          nv_wo32(bios, i, nv_rd32(bios, 0x300000 + i));
   187          }
   188  
   189          /* check the PCI record header */
   190          pcir = nv_ro16(bios, 0x0018);
   191          if (bios->data[pcir + 0] != 'P' ||
                    ^^^^^^^^^^^^^^^^^^^^
NULL deref.

   192              bios->data[pcir + 1] != 'C' ||
   193              bios->data[pcir + 2] != 'I' ||
   194              bios->data[pcir + 3] != 'R') {
   195                  bios->size = 0;
   196                  kfree(bios->data);
   197          }
   198  
   199  out:
   200          /* disable access to rom */
   201          nv_wr32(bios, pcireg, access);
   202  }

regards,
dan carpenter


More information about the dri-devel mailing list