diff options
author | Axel Lin <axel.lin@gmail.com> | 2010-08-04 14:34:10 +0800 |
---|---|---|
committer | Liam Girdwood <lrg@slimlogic.co.uk> | 2010-08-11 11:38:02 +0100 |
commit | 1b69d8e3fde65ab2b7c5e1d4adee59e8a67b0b4f (patch) | |
tree | 3cde765db7444f0c3d2964f4b6a6a7b3ad08c743 /drivers/regulator | |
parent | 4cc2e3934bd74afbdff595ad2183e8aa25d0a0f2 (diff) | |
download | op-kernel-dev-1b69d8e3fde65ab2b7c5e1d4adee59e8a67b0b4f.zip op-kernel-dev-1b69d8e3fde65ab2b7c5e1d4adee59e8a67b0b4f.tar.gz |
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')
-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 03e55a1..ab67298 100644 --- a/drivers/regulator/max8998.c +++ b/drivers/regulator/max8998.c @@ -119,7 +119,7 @@ static int max8998_list_voltage(struct regulator_dev *rdev, int ldo = max8998_get_ldo(rdev); int val; - if (ldo > ARRAY_SIZE(ldo_voltage_map)) + if (ldo >= ARRAY_SIZE(ldo_voltage_map)) return -EINVAL; desc = ldo_voltage_map[ldo]; @@ -306,7 +306,7 @@ static int max8998_set_voltage(struct regulator_dev *rdev, u8 val; bool en_ramp = false; - if (ldo > ARRAY_SIZE(ldo_voltage_map)) + if (ldo >= ARRAY_SIZE(ldo_voltage_map)) return -EINVAL; desc = ldo_voltage_map[ldo]; |