dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: David Airlie <airlied@linux.ie>
Cc: Thomas Hellstrom <thellstrom@vmware.com>,
	dri-devel@lists.freedesktop.org
Subject: re: drm: update VIA driver to 2.7.2
Date: Wed, 11 Dec 2013 13:11:50 +0300	[thread overview]
Message-ID: <20131211101150.GA23420@elgon.mountain> (raw)

Hello Dave Airlie,

The patch 925142431bd6: "drm: update VIA driver to 2.7.2" from Nov
12, 2005, leads to the following static checker warning:

	drivers/gpu/drm/via/via_irq.c:242 via_driver_irq_wait()
	error: buffer overflow 'masks' 4 <= 5

drivers/gpu/drm/via/via_irq.c
   225          if (irq >= drm_via_irq_num) {

This used to test for "irq >= dev_priv->num_irqs" but we raise it to
drm_via_irq_num.

   226                  DRM_ERROR("Trying to wait on unknown irq %d\n", irq);
   227                  return -EINVAL;
   228          }
   229  
   230          real_irq = dev_priv->irq_map[irq];
   231  
   232          if (real_irq < 0) {
   233                  DRM_ERROR("Video IRQ %d not available on this hardware.\n",
   234                            irq);
   235                  return -EINVAL;
   236          }
   237  
   238          masks = dev_priv->irq_masks;

There are dev_priv->num_irqs elements in the dev_priv->irq_masks[]
array.

   239          cur_irq = dev_priv->via_irqs + real_irq;
   240  
   241          if (masks[real_irq][2] && !force_sequence) {
   242                  DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
   243                              ((VIA_READ(masks[irq][2]) & masks[irq][3]) ==
                                               ^^^^^^^^^^
Smatch is complaining because "irq" is out of bounds now that we raised
the limit on line 225.  Should we be using "masks[real_irq][2]" here?

   244                               masks[irq][4]));
   245                  cur_irq_sequence = atomic_read(&cur_irq->irq_received);
   246          } else {
   247                  DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
   248                              (((cur_irq_sequence =
   249                                 atomic_read(&cur_irq->irq_received)) -
   250                                *sequence) <= (1 << 23)));
   251          }

regards,
dan carpenter

                 reply	other threads:[~2013-12-11 10:11 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=20131211101150.GA23420@elgon.mountain \
    --to=dan.carpenter@oracle.com \
    --cc=airlied@linux.ie \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=thellstrom@vmware.com \
    /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