linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Jean Delvare <khali@linux-fr.org>
Cc: Dan Carpenter <error27@gmail.com>,
	Mike Frysinger <vapier@gentoo.org>,
	Greg Kroah-Hartman <gregkh@suse.de>,
	Richard Purdie <rpurdie@linux.intel.com>,
	linux-input@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [patch] input: off by one in pcf8574_kp_irq_handler()
Date: Sat, 5 Jun 2010 00:36:00 -0700	[thread overview]
Message-ID: <20100605073559.GA29303@core.coreip.homeip.net> (raw)
In-Reply-To: <20100605085002.064a6888@hyperion.delvare>

On Sat, Jun 05, 2010 at 08:50:02AM +0200, Jean Delvare wrote:
> Hi Dan,
> 
> On Sat, 5 Jun 2010 01:19:39 +0200, Dan Carpenter wrote:
> > If nextstate == ARRAY_SIZE(lp->btncode), then we read one past the end of
> > the array on the next line.
> > 
> > This fixes a smatch warning:
> > drivers/input/misc/pcf8574_keypad.c +74 pcf8574_kp_irq_handler(8)
> > 	error: buffer overflow 'lp->btncode' 17 <= 17
> > 
> > Signed-off-by: Dan Carpenter <error27@gmail.com>
> > 
> > diff --git a/drivers/input/misc/pcf8574_keypad.c b/drivers/input/misc/pcf8574_keypad.c
> > index 0ac47d2..4b42ffc 100644
> > --- a/drivers/input/misc/pcf8574_keypad.c
> > +++ b/drivers/input/misc/pcf8574_keypad.c
> > @@ -69,7 +69,7 @@ static irqreturn_t pcf8574_kp_irq_handler(int irq, void *dev_id)
> >  	unsigned char nextstate = read_state(lp);
> >  
> >  	if (lp->laststate != nextstate) {
> > -		int key_down = nextstate <= ARRAY_SIZE(lp->btncode);
> > +		int key_down = nextstate < ARRAY_SIZE(lp->btncode);
> >  		unsigned short keycode = key_down ?
> >  			lp->btncode[nextstate] : lp->btncode[lp->laststate];
> >  
> 
> Good catch.
> 
> Acked-by: Jean Delvare <khali@linux-fr.org>
> 

Applied to 'for-linus', thanks Dan.

-- 
Dmitry

      reply	other threads:[~2010-06-05  7:36 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-04 23:19 [patch] input: off by one in pcf8574_kp_irq_handler() Dan Carpenter
2010-06-05  6:50 ` Jean Delvare
2010-06-05  7:36   ` Dmitry Torokhov [this message]

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=20100605073559.GA29303@core.coreip.homeip.net \
    --to=dmitry.torokhov@gmail.com \
    --cc=error27@gmail.com \
    --cc=gregkh@suse.de \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=khali@linux-fr.org \
    --cc=linux-input@vger.kernel.org \
    --cc=rpurdie@linux.intel.com \
    --cc=vapier@gentoo.org \
    /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;
as well as URLs for NNTP newsgroup(s).