regulator: ab8500 - fix off-by-one value range checking for selector
PATCH 1/1 regulator: ab8500 - fix off-by-one value range checking for selector
selector is used as array index of info->supported_voltages Thus the valid value range should be 0 .. info->voltages_len -1
Signed-off-by Axel Lin <[email protected]>
--- drivers/regulator/ab8500.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/regulator/ab8500.c +1 -1
@@ -157,7 +157,7 @@ static int ab8500_list_voltage(struct regulator_dev *rdev, unsigned selector)if (info->fixed_uV)return info->fixed_uV; -if (selector > info->voltages_len) +if (selector >= info->voltages_len)return -EINVAL ;return info->supported_voltages[selector];
Signature · 1 line
1.7.2
Quoted 4 lines · Axel Lin
selector is used as array index of
info->supported_voltagesThus the valid value range should be 0 ..info->voltages_len-1Signed-off-by Axel Lin <[email protected]>
Acked-by Mark Brown <[email protected]>