From: Axel Lin Date: Sat, 4 Sep 2010 15:06:41 +0000 (+0800) Subject: regulator: ab8500 - fix off-by-one value range checking for selector X-Git-Tag: v2.6.36-rc5~29^2~2 X-Git-Url: https://openfabrics.org/gitweb/?a=commitdiff_plain;h=49990e6efe576b8707584398f93198b5aa182ab7;p=~shefty%2Frdma-dev.git 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 Acked-by: Mark Brown Signed-off-by: Liam Girdwood --- diff --git a/drivers/regulator/ab8500.c b/drivers/regulator/ab8500.c index 3d09580dc88..28c7ae67cec 100644 --- a/drivers/regulator/ab8500.c +++ b/drivers/regulator/ab8500.c @@ -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];