Browse Source

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 <error27@gmail.com>
Signed-off-by: Ben Dooks <ben-linux@fluff.org>
Dan Carpenter 15 years ago
parent
commit
42df64b1f8
1 changed files with 1 additions and 1 deletions
  1. 1 1
      drivers/i2c/busses/i2c-stu300.c

+ 1 - 1
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++;