]> bbs.cooldavid.org Git - net-next-2.6.git/commitdiff
Input: pcf8574_keypad - fix off by one in pcf8574_kp_irq_handler()
authorDan Carpenter <error27@gmail.com>
Sat, 5 Jun 2010 07:34:08 +0000 (00:34 -0700)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Sat, 5 Jun 2010 07:34:45 +0000 (00:34 -0700)
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>
Acked-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
drivers/input/misc/pcf8574_keypad.c

index 5c3ac4e0b055837976624cbd3ef1873cc81d82c6..376e54df4763b1eadfd9eb6b20814ffa3671bb99 100644 (file)
@@ -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];