linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jean Delvare <khali@linux-fr.org>
To: Dan Carpenter <error27@gmail.com>
Cc: Dmitry Torokhov <dmitry.torokhov@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 08:50:02 +0200	[thread overview]
Message-ID: <20100605085002.064a6888@hyperion.delvare> (raw)
In-Reply-To: <20100604231939.GJ5483@bicker>

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>

-- 
Jean Delvare

  reply	other threads:[~2010-06-05  6:50 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 [this message]
2010-06-05  7:36   ` Dmitry Torokhov

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=20100605085002.064a6888@hyperion.delvare \
    --to=khali@linux-fr.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=error27@gmail.com \
    --cc=gregkh@suse.de \
    --cc=kernel-janitors@vger.kernel.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).