From: Adrian Bunk This patch fixes two possible off by one errors found by the Coverity checker (look at the period[i] and delay[j] in the two first unchanged lines). Signed-off-by: Adrian Bunk Cc: Vojtech Pavlik Cc: Dmitry Torokhov Signed-off-by: Andrew Morton --- drivers/input/keyboard/atkbd.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) diff -puN drivers/input/keyboard/atkbd.c~drivers-input-keyboard-atkbdc-fix-off-by-one-errors drivers/input/keyboard/atkbd.c --- 25/drivers/input/keyboard/atkbd.c~drivers-input-keyboard-atkbdc-fix-off-by-one-errors 2005-05-13 23:18:02.000000000 -0700 +++ 25-akpm/drivers/input/keyboard/atkbd.c 2005-05-13 23:18:38.000000000 -0700 @@ -465,8 +465,10 @@ static int atkbd_event(struct input_dev if (atkbd->softrepeat) return 0; i = j = 0; - while (i < 32 && period[i] < dev->rep[REP_PERIOD]) i++; - while (j < 4 && delay[j] < dev->rep[REP_DELAY]) j++; + while (i < 31 && period[i] < dev->rep[REP_PERIOD]) + i++; + while (j < 3 && delay[j] < dev->rep[REP_DELAY]) + j++; dev->rep[REP_PERIOD] = period[i]; dev->rep[REP_DELAY] = delay[j]; param[0] = i | (j << 5); _