Skip to content

Commit

Permalink
ab3100: fix off-by-one value range checking for voltage selector
Browse files Browse the repository at this point in the history
We use voltage selector as an array index for typ_voltages.
Thus the valid range for voltage selector should be 0..voltages_len-1.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Acked-by: Linus Walleij <linus.walleij@stericsson.com>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
  • Loading branch information
Axel Lin authored and Liam Girdwood committed Jul 27, 2010
1 parent b37fa16 commit 979da89
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/regulator/ab3100.c
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ static int ab3100_list_voltage_regulator(struct regulator_dev *reg,
{
struct ab3100_regulator *abreg = reg->reg_data;

if (selector > abreg->voltages_len)
if (selector >= abreg->voltages_len)
return -EINVAL;
return abreg->typ_voltages[selector];
}
Expand Down Expand Up @@ -318,7 +318,7 @@ static int ab3100_get_voltage_regulator(struct regulator_dev *reg)
regval &= 0xE0;
regval >>= 5;

if (regval > abreg->voltages_len) {
if (regval >= abreg->voltages_len) {
dev_err(&reg->dev,
"regulator register %02x contains an illegal voltage setting\n",
abreg->regreg);
Expand Down

0 comments on commit 979da89

Please sign in to comment.