From: Adrian Bunk Date: Tue, 17 May 2005 04:53:38 +0000 (-0700) Subject: [PATCH] drivers/input/keyboard/atkbd.c: fix off by one errors X-Git-Tag: v2.6.12-rc5~135 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=53b21689ba567ad437e4d7917dd9da54a8d6fd5c;p=linux-2.6 [PATCH] drivers/input/keyboard/atkbd.c: fix off by one errors 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 Signed-off-by: Linus Torvalds --- diff --git a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c index ff66ed4ee2..79c332f16f 100644 --- a/drivers/input/keyboard/atkbd.c +++ b/drivers/input/keyboard/atkbd.c @@ -465,8 +465,10 @@ static int atkbd_event(struct input_dev *dev, unsigned int type, unsigned int co 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);