[PATCH] regulator: rc5t583: Fix off-by-one valid range checking forselector
From: Axel Lin
Date: Wed Apr 04 2012 - 10:38:13 EST
The valid selector should be 0 ... nsteps-1.
Signed-off-by: Axel Lin <axel.lin@xxxxxxxxx>
---
drivers/regulator/rc5t583-regulator.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/drivers/regulator/rc5t583-regulator.c b/drivers/regulator/rc5t583-regulator.c
index cac8a2a..dc9ebb9 100644
--- a/drivers/regulator/rc5t583-regulator.c
+++ b/drivers/regulator/rc5t583-regulator.c
@@ -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;
}
--
1.7.5.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/