ab3100: fix off-by-one value range checking for voltage selector
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>
This commit is contained in:
parent
b37fa16e78
commit
979da89a9c
1 changed files with 2 additions and 2 deletions
|
@ -286,7 +286,7 @@ static int ab3100_list_voltage_regulator(struct regulator_dev *reg,
|
||||||
{
|
{
|
||||||
struct ab3100_regulator *abreg = reg->reg_data;
|
struct ab3100_regulator *abreg = reg->reg_data;
|
||||||
|
|
||||||
if (selector > abreg->voltages_len)
|
if (selector >= abreg->voltages_len)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
return abreg->typ_voltages[selector];
|
return abreg->typ_voltages[selector];
|
||||||
}
|
}
|
||||||
|
@ -318,7 +318,7 @@ static int ab3100_get_voltage_regulator(struct regulator_dev *reg)
|
||||||
regval &= 0xE0;
|
regval &= 0xE0;
|
||||||
regval >>= 5;
|
regval >>= 5;
|
||||||
|
|
||||||
if (regval > abreg->voltages_len) {
|
if (regval >= abreg->voltages_len) {
|
||||||
dev_err(®->dev,
|
dev_err(®->dev,
|
||||||
"regulator register %02x contains an illegal voltage setting\n",
|
"regulator register %02x contains an illegal voltage setting\n",
|
||||||
abreg->regreg);
|
abreg->regreg);
|
||||||
|
|
Loading…
Reference in a new issue