Skip to content

Commit

Permalink
regulator: ab8500 - fix off-by-one value range checking for selector
Browse files Browse the repository at this point in the history
selector is used as array index of info->supported_voltages
Thus the valid value range should be 0 .. info->voltages_len -1

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Acked-by: Mark Brown <broonie@openource.wolfsonmicro.com>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
  • Loading branch information
Axel Lin authored and Liam Girdwood committed Sep 5, 2010
1 parent d06563c commit 49990e6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/regulator/ab8500.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ static int ab8500_list_voltage(struct regulator_dev *rdev, unsigned selector)
if (info->fixed_uV)
return info->fixed_uV;

if (selector > info->voltages_len)
if (selector >= info->voltages_len)
return -EINVAL;

return info->supported_voltages[selector];
Expand Down

0 comments on commit 49990e6

Please sign in to comment.