From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dan Carpenter Subject: re: drm/nouveau/bios: fetch the vbios from PROM using only aligned 32-bit accesses Date: Wed, 2 Apr 2014 19:55:29 +0300 Message-ID: <20140402165529.GB10002@mwanda> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from userp1040.oracle.com (userp1040.oracle.com [156.151.31.81]) by gabe.freedesktop.org (Postfix) with ESMTP id D21D66EBBB for ; Wed, 2 Apr 2014 09:55:40 -0700 (PDT) Content-Disposition: inline List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" To: martin.peres@free.fr Cc: dri-devel@lists.freedesktop.org List-Id: dri-devel@lists.freedesktop.org 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