Skip to contentSkip to conversation

regulator: rc5t583: Fix off-by-one valid range checking for selector

PATCH Applied Axel Lin 2 participants 2 messages Apr 4, 2012 – Apr 5, 2012 Voltage and current regulator framework

lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/1 regulator: rc5t583: Fix off-by-one valid range checking for selector

The valid selector should be 0 ... nsteps-1.

---
 drivers/regulator/rc5t583-regulator.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/regulator/rc5t583-regulator.c +1 -1
index cac8a2a..dc9ebb9 100644
@@ -131,7 +131,7 @@ static int rc5t583_set_voltage_sel(struct regulator_dev *rdev,
 	struct rc5t583_regulator *reg = rdev_get_drvdata(rdev);
 	struct rc5t583_regulator_info *ri = reg->reg_info;
 	int ret;
-	if (selector > ri->nsteps) {
+	if (selector >= ri->nsteps) {
 		dev_err(&rdev->dev, "Invalid selector 0x%02x\n", selector);
 		return -EINVAL;
 	}
Signature · 1 line
1.7.5.4
Applied
#1 lore raw
Quoted 1 line · Axel Lin

The valid selector should be 0 ... nsteps-1.

Applied, thanks.