i2c-stu300: off by one issue
authorDan Carpenter <error27@gmail.com>
Wed, 7 Apr 2010 09:22:58 +0000 (12:22 +0300)
committerBen Dooks <ben-linux@fluff.org>
Tue, 20 Apr 2010 00:17:13 +0000 (01:17 +0100)
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>
drivers/i2c/busses/i2c-stu300.c

index 1f5b38be73bc41277f1ab6176dc89f208b934ba9..495be451d326c5b860648e94ccad189c9438c0b2 100644 (file)
@@ -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++;