diff options
author | Axel Lin <axel.lin@gmail.com> | 2010-08-04 02:34:10 -0400 |
---|---|---|
committer | Liam Girdwood <lrg@slimlogic.co.uk> | 2010-08-11 06:38:02 -0400 |
commit | 1b69d8e3fde65ab2b7c5e1d4adee59e8a67b0b4f (patch) | |
tree | 3cde765db7444f0c3d2964f4b6a6a7b3ad08c743 /drivers/regulator/max8998.c | |
parent | 4cc2e3934bd74afbdff595ad2183e8aa25d0a0f2 (diff) |
max8998: fix off-by-one value range checking
In max8998_list_voltage() and max8998_set_voltage(),
we use ldo as array index of ldo_voltage_map.
Thus the valid range should be 0 .. ARRAY_SIZE(ldo_voltage_map)-1.
Signed-off-by: Axel Lin <axel.lin@gmail.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
Diffstat (limited to 'drivers/regulator/max8998.c')
-rw-r--r-- | drivers/regulator/max8998.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/regulator/max8998.c b/drivers/regulator/max8998.c index 03e55a18a2ad..ab67298799f9 100644 --- a/drivers/regulator/max8998.c +++ b/drivers/regulator/max8998.c | |||
@@ -119,7 +119,7 @@ static int max8998_list_voltage(struct regulator_dev *rdev, | |||
119 | int ldo = max8998_get_ldo(rdev); | 119 | int ldo = max8998_get_ldo(rdev); |
120 | int val; | 120 | int val; |
121 | 121 | ||
122 | if (ldo > ARRAY_SIZE(ldo_voltage_map)) | 122 | if (ldo >= ARRAY_SIZE(ldo_voltage_map)) |
123 | return -EINVAL; | 123 | return -EINVAL; |
124 | 124 | ||
125 | desc = ldo_voltage_map[ldo]; | 125 | desc = ldo_voltage_map[ldo]; |
@@ -306,7 +306,7 @@ static int max8998_set_voltage(struct regulator_dev *rdev, | |||
306 | u8 val; | 306 | u8 val; |
307 | bool en_ramp = false; | 307 | bool en_ramp = false; |
308 | 308 | ||
309 | if (ldo > ARRAY_SIZE(ldo_voltage_map)) | 309 | if (ldo >= ARRAY_SIZE(ldo_voltage_map)) |
310 | return -EINVAL; | 310 | return -EINVAL; |
311 | 311 | ||
312 | desc = ldo_voltage_map[ldo]; | 312 | desc = ldo_voltage_map[ldo]; |