dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: martin.peres@free.fr
Cc: dri-devel@lists.freedesktop.org
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	[thread overview]
Message-ID: <20140402165529.GB10002@mwanda> (raw)

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

                 reply	other threads:[~2014-04-02 16:55 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140402165529.GB10002@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=martin.peres@free.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox