From: Axel Lin Date: Wed, 4 Aug 2010 06:34:10 +0000 (+0800) Subject: max8998: fix off-by-one value range checking X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=1b69d8e3fde65ab2b7c5e1d4adee59e8a67b0b4f;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git max8998: fix off-by-one value range checking In max8998_list_voltage() and max8998_set_voltage(), we use ldo as array index of ldo_voltage_map. Thus the valid range should be 0 .. ARRAY_SIZE(ldo_voltage_map)-1. Signed-off-by: Axel Lin Acked-by: Kyungmin Park Acked-by: Mark Brown Signed-off-by: Liam Girdwood --- diff --git a/drivers/regulator/max8998.c b/drivers/regulator/max8998.c index 03e55a18a2ad..ab67298799f9 100644 --- a/drivers/regulator/max8998.c +++ b/drivers/regulator/max8998.c @@ -119,7 +119,7 @@ static int max8998_list_voltage(struct regulator_dev *rdev, int ldo = max8998_get_ldo(rdev); int val; - if (ldo > ARRAY_SIZE(ldo_voltage_map)) + if (ldo >= ARRAY_SIZE(ldo_voltage_map)) return -EINVAL; desc = ldo_voltage_map[ldo]; @@ -306,7 +306,7 @@ static int max8998_set_voltage(struct regulator_dev *rdev, u8 val; bool en_ramp = false; - if (ldo > ARRAY_SIZE(ldo_voltage_map)) + if (ldo >= ARRAY_SIZE(ldo_voltage_map)) return -EINVAL; desc = ldo_voltage_map[ldo];