mirror of
https://github.com/torvalds/linux.git
synced 2024-11-11 06:31:49 +00:00
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: bdcd117757
("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>
This commit is contained in:
parent
33f369efbc
commit
55cca73931
@ -2958,9 +2958,10 @@ static int _regulator_list_voltage(struct regulator_dev *rdev,
|
||||
return rdev->desc->fixed_uV;
|
||||
|
||||
if (ops->list_voltage) {
|
||||
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;
|
||||
if (lock)
|
||||
regulator_lock(rdev);
|
||||
ret = ops->list_voltage(rdev, selector);
|
||||
@ -3110,9 +3111,10 @@ int regulator_list_hardware_vsel(struct regulator *regulator,
|
||||
struct regulator_dev *rdev = regulator->rdev;
|
||||
const struct regulator_ops *ops = rdev->desc->ops;
|
||||
|
||||
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;
|
||||
if (ops->set_voltage_sel != regulator_set_voltage_sel_regmap)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
|
@ -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];
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user