i2c: off by one issue
Subsystems (2)
PATCH 1/1 i2c: 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 <[email protected]>
---
I will be offline for a while, sorry if I delay replying.
drivers/i2c/busses/i2c-stu300.c +1 -1
@@ -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++;
Quoted 2 lines
If we don't find the correct rate, we want to end the loop with "i" pointing to the last element in the array.
Good catch!
Acked-by Linus Walleij <[email protected]>
Yours,
Linus Walleij