From: Axel Lin Date: Sun, 22 Aug 2010 14:38:15 +0000 (+0800) Subject: regulator: tps6586x-regulator - fix value range checking for val X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=327531bada36e5786b13bb6918ad8afc545adfa2;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git regulator: tps6586x-regulator - fix value range checking for val val is used as array index of ri->voltages. Thus the valid value range should be 0 .. ri->desc.n_voltages - 1. Signed-off-by: Axel Lin Acked-by: Mark Brown Signed-off-by: Liam Girdwood --- diff --git a/drivers/regulator/tps6586x-regulator.c b/drivers/regulator/tps6586x-regulator.c index 8cff1413a147..facd439d0f12 100644 --- a/drivers/regulator/tps6586x-regulator.c +++ b/drivers/regulator/tps6586x-regulator.c @@ -133,7 +133,7 @@ static int tps6586x_ldo_get_voltage(struct regulator_dev *rdev) mask = ((1 << ri->volt_nbits) - 1) << ri->volt_shift; val = (val & mask) >> ri->volt_shift; - if (val > ri->desc.n_voltages) + if (val >= ri->desc.n_voltages) BUG(); return ri->voltages[val] * 1000;