[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <1367676147.5124.1.camel@phoenix>
Date: Sat, 04 May 2013 22:02:27 +0800
From: Axel Lin <axel.lin@...ics.com>
To: Mark Brown <broonie@...nel.org>
Cc: "Andrii.Tseglytskyi" <andrii.tseglytskyi@...com>,
Nishanth Menon <nm@...com>, Liam Girdwood <lrg@...com>,
linux-kernel@...r.kernel.org
Subject: [PATCH] regulator: ti-abb: Fix off-by-one valid range checking for
abb->current_info_idx
abb->current_info_idx is used as array subscript to access volt_table,
thus the valid value range should be 0 ... desc->n_voltages - 1.
Signed-off-by: Axel Lin <axel.lin@...ics.com>
---
drivers/regulator/ti-abb-regulator.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/regulator/ti-abb-regulator.c b/drivers/regulator/ti-abb-regulator.c
index c1870ea..870d209 100644
--- a/drivers/regulator/ti-abb-regulator.c
+++ b/drivers/regulator/ti-abb-regulator.c
@@ -387,8 +387,8 @@ static int ti_abb_get_voltage_sel(struct regulator_dev *rdev)
return -EINVAL;
}
- if (abb->current_info_idx > (int)desc->n_voltages) {
- dev_err(dev, "%s: Corrupted data? idx(%d) > n_voltages(%d)\n",
+ if (abb->current_info_idx >= (int)desc->n_voltages) {
+ dev_err(dev, "%s: Corrupted data? idx(%d) >= n_voltages(%d)\n",
__func__, abb->current_info_idx, desc->n_voltages);
return -EINVAL;
}
--
1.8.1.2
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists