From: Roel Kluin Date: Mon, 26 Oct 2009 11:37:11 +0000 (+0100) Subject: regulator: keep index within bounds in da9034_get_ldo12_voltage() X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=495353a3f7fbb11e5100c9258365ff65a4834b37;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git regulator: keep index within bounds in da9034_get_ldo12_voltage() If selector equals ARRAY_SIZE(da9034_ldo12_data), that is one too large already. Signed-off-by: Roel Kluin Acked-by: Mark Brown Signed-off-by: Liam Girdwood --- diff --git a/drivers/regulator/da903x.c b/drivers/regulator/da903x.c index aa224d936e0d..f8c4661a7a81 100644 --- a/drivers/regulator/da903x.c +++ b/drivers/regulator/da903x.c @@ -331,7 +331,7 @@ static int da9034_get_ldo12_voltage(struct regulator_dev *rdev) static int da9034_list_ldo12_voltage(struct regulator_dev *rdev, unsigned selector) { - if (selector > ARRAY_SIZE(da9034_ldo12_data)) + if (selector >= ARRAY_SIZE(da9034_ldo12_data)) return -EINVAL; return da9034_ldo12_data[selector] * 1000; }