From: Dan Carpenter Date: Wed, 7 Apr 2010 09:22:58 +0000 (+0300) Subject: i2c-stu300: off by one issue X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=42df64b1f83fa9b786067a0b5a3aca0fbb2d8db8;p=GitHub%2Fexynos8895%2Fandroid_kernel_samsung_universal8895.git i2c-stu300: off by one issue If we don't find the correct rate, we want to end the loop with "i" pointing to the last element in the array. Signed-off-by: Dan Carpenter Signed-off-by: Ben Dooks --- diff --git a/drivers/i2c/busses/i2c-stu300.c b/drivers/i2c/busses/i2c-stu300.c index 1f5b38be73bc..495be451d326 100644 --- a/drivers/i2c/busses/i2c-stu300.c +++ b/drivers/i2c/busses/i2c-stu300.c @@ -498,7 +498,7 @@ static int stu300_set_clk(struct stu300_dev *dev, unsigned long clkrate) int i = 0; /* Locate the apropriate clock setting */ - while (i < ARRAY_SIZE(stu300_clktable) && + while (i < ARRAY_SIZE(stu300_clktable) - 1 && stu300_clktable[i].rate < clkrate) i++;