Skip to content

Commit 979da89

Browse files
AxelLinLiam Girdwood
authored andcommitted
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>
1 parent b37fa16 commit 979da89

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎drivers/regulator/ab3100.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ static int ab3100_list_voltage_regulator(struct regulator_dev *reg,
286286
{
287287
struct ab3100_regulator *abreg = reg->reg_data;
288288

289-
if (selector > abreg->voltages_len)
289+
if (selector >= abreg->voltages_len)
290290
return -EINVAL;
291291
return abreg->typ_voltages[selector];
292292
}
@@ -318,7 +318,7 @@ static int ab3100_get_voltage_regulator(struct regulator_dev *reg)
318318
regval &= 0xE0;
319319
regval >>= 5;
320320

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

0 commit comments

Comments
 (0)