From: Dan Carpenter Date: Wed, 7 Apr 2010 09:22:58 +0000 (+0300) Subject: i2c-stu300: off by one issue X-Git-Tag: firefly_0821_release~9833^2~2318^2 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=42df64b1f83fa9b786067a0b5a3aca0fbb2d8db8;p=firefly-linux-kernel-4.4.55.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++;