From: Dan Carpenter Date: Wed, 7 Apr 2010 09:22:58 +0000 (+0300) Subject: i2c-stu300: off by one issue X-Git-Tag: v2.6.34-rc6~71^2 X-Git-Url: https://openfabrics.org/gitweb/?a=commitdiff_plain;h=42df64b1f83fa9b786067a0b5a3aca0fbb2d8db8;p=~emulex%2Finfiniband.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 1f5b38be73b..495be451d32 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++;