Re: [patch] input: off by one in pcf8574_kp_irq_handler()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
> 
> 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@xxxxxxxxxxxx>

-- 
Jean Delvare
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux