diff options
author | Claudiu Beznea <claudiu.beznea@microchip.com> | 2020-11-25 18:25:47 +0100 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2020-11-26 14:08:15 +0100 |
commit | 55cca73931c3a08eb74f5ad06e88304af7a292e0 (patch) | |
tree | 51fc1fa1d293addeceef42688992f98f4ede7485 /drivers/regulator/helpers.c | |
parent | regulator: mcp16502-regulator: fix spelling mistake (diff) | |
download | linux-55cca73931c3a08eb74f5ad06e88304af7a292e0.tar.xz linux-55cca73931c3a08eb74f5ad06e88304af7a292e0.zip |
regulator: core: return zero for selectors lower than linear_min_sel
Selectors lower than linear_min_sel should not be considered invalid.
Thus return zero in case _regulator_list_voltage(),
regulator_list_hardware_vsel() or regulator_list_voltage_table()
receives such selectors as argument.
Fixes: bdcd1177578c ("regulator: core: validate selector against linear_min_sel")
Reported-by: Jon Hunter <jonathanh@nvidia.com>
Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Link: https://lore.kernel.org/r/1606325147-606-1-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 | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/regulator/helpers.c b/drivers/regulator/helpers.c index 974f1a63993d..f42b394a0c46 100644 --- a/drivers/regulator/helpers.c +++ b/drivers/regulator/helpers.c @@ -647,9 +647,10 @@ int regulator_list_voltage_table(struct regulator_dev *rdev, return -EINVAL; } - if (selector >= rdev->desc->n_voltages || - selector < rdev->desc->linear_min_sel) + if (selector >= rdev->desc->n_voltages) return -EINVAL; + if (selector < rdev->desc->linear_min_sel) + return 0; return rdev->desc->volt_table[selector]; } |