regulator: keep index within bounds in da9034_get_ldo12_voltage()
authorRoel Kluin <roel.kluin@gmail.com>
Mon, 26 Oct 2009 11:37:11 +0000 (12:37 +0100)
committerLiam Girdwood <lrg@slimlogic.co.uk>
Thu, 17 Dec 2009 10:27:25 +0000 (10:27 +0000)
If selector equals ARRAY_SIZE(da9034_ldo12_data), that is one too
large already.

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
drivers/regulator/da903x.c

index aa224d936e0de4c92665faf14115bc5592e63bde..f8c4661a7a81ae82705b51691669e230553203b1 100644 (file)
@@ -331,7 +331,7 @@ static int da9034_get_ldo12_voltage(struct regulator_dev *rdev)
 static int da9034_list_ldo12_voltage(struct regulator_dev *rdev,
                                     unsigned selector)
 {
-       if (selector > ARRAY_SIZE(da9034_ldo12_data))
+       if (selector >= ARRAY_SIZE(da9034_ldo12_data))
                return -EINVAL;
        return da9034_ldo12_data[selector] * 1000;
 }