Skip to content

Commit

Permalink
regulator/lp3971: vol_map out of bounds in lp3971_{ldo,dcdc}_set_volt…
Browse files Browse the repository at this point in the history
…age()

After `for (val = LDO_VOL_MIN_IDX; val <= LDO_VOL_MAX_IDX; val++)', if no break
occurs, val reaches LDO_VOL_MIN_IDX + 1, which is out of bounds for
ldo45_voltage_map[] and ldo123_voltage_map[].

Similarly BUCK_TARGET_VOL_MAX_IDX + 1 is out of bounds for buck_voltage_map[].

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>
  • Loading branch information
RoelKluin authored and Liam Girdwood committed Feb 12, 2010
1 parent 973e9a2 commit 62737d4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/regulator/lp3971.c
Expand Up @@ -183,7 +183,7 @@ static int lp3971_ldo_set_voltage(struct regulator_dev *dev,
if (vol_map[val] >= min_vol)
break;

if (vol_map[val] > max_vol)
if (val > LDO_VOL_MAX_IDX || vol_map[val] > max_vol)
return -EINVAL;

return lp3971_set_bits(lp3971, LP3971_LDO_VOL_CONTR_REG(ldo),
Expand Down Expand Up @@ -272,7 +272,7 @@ static int lp3971_dcdc_set_voltage(struct regulator_dev *dev,
if (vol_map[val] >= min_vol)
break;

if (vol_map[val] > max_vol)
if (val > BUCK_TARGET_VOL_MAX_IDX || vol_map[val] > max_vol)
return -EINVAL;

ret = lp3971_set_bits(lp3971, LP3971_BUCK_TARGET_VOL1_REG(buck),
Expand Down

0 comments on commit 62737d4

Please sign in to comment.