diff options
author | Claudiu Beznea <claudiu.beznea@microchip.com> | 2020-11-13 18:21:05 +0300 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2020-11-13 19:13:11 +0300 |
commit | bdcd1177578cd5556f7494da86d5038db8203a16 (patch) | |
tree | ba69542d018dafb2ddcf3347952038339d3c3817 /drivers/regulator/helpers.c | |
parent | 842f44806efaddfae5ecff8f143c2607a4fa65d7 (diff) | |
download | linux-bdcd1177578cd5556f7494da86d5038db8203a16.tar.xz |
regulator: core: validate selector against linear_min_sel
There are regulators who's min selector is not zero. Selectors loops
(looping b/w zero and regulator::desc::n_voltages) might throw errors
because invalid selectors are used (lower than
regulator::desc::linear_min_sel). For this situations validate selectors
against regulator::desc::linear_min_sel.
Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Link: https://lore.kernel.org/r/1605280870-32432-2-git-send-email-claudiu.beznea@microchip.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/regulator/helpers.c')
-rw-r--r-- | drivers/regulator/helpers.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/regulator/helpers.c b/drivers/regulator/helpers.c index e4bb09bbd3fa..974f1a63993d 100644 --- a/drivers/regulator/helpers.c +++ b/drivers/regulator/helpers.c @@ -647,7 +647,8 @@ int regulator_list_voltage_table(struct regulator_dev *rdev, return -EINVAL; } - if (selector >= rdev->desc->n_voltages) + if (selector >= rdev->desc->n_voltages || + selector < rdev->desc->linear_min_sel) return -EINVAL; return rdev->desc->volt_table[selector]; |