Skip to contentSkip to conversation

regulator: keep index within bounds in da9034_get_ldo12_voltage()

PATCH Liam Girdwood 1 participant 1 message Oct 26, 2009 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Liam Girdwood

author Applied
#1 lore raw
Quoted 13 lines · Roel Kluin

If selector equals ARRAY_SIZE(da9034_ldo12_data), that is one too large already.

---
 drivers/regulator/da903x.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/regulator/da903x.c +0 -0
index aa224d9..f8c4661 100644

drivers/regulator/da903x.c static int da9034_get_ldo12_voltage(struct regulator_dev *rdev) · line 337

Quoted 8 lines
drivers/regulator/da903x.c +1 -1
@@ -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;
 }

Applied.

Thanks

Liam