summaryrefslogtreecommitdiffstats
path: root/drivers/regulator/pv88090-regulator.c
diff options
context:
space:
mode:
authorEric Jeong <eric.jeong.opensource@diasemi.com>2017-08-30 10:54:27 +0200
committerMark Brown <broonie@kernel.org>2017-08-30 17:12:17 +0200
commit8986a11978373400a7e880b413c43ca229d7a8a8 (patch)
tree41fbddd7f862684af7efb46dedc2dd313a4cdc89 /drivers/regulator/pv88090-regulator.c
parentLinux v4.13-rc1 (diff)
downloadlinux-8986a11978373400a7e880b413c43ca229d7a8a8.tar.xz
linux-8986a11978373400a7e880b413c43ca229d7a8a8.zip
regulator: pv88090: Exception handling for out of bounds
This is a patch for exception handlding that the index of array is out of bounds. And the definitions have been updated to use proper device name. Signed-off-by: Eric Jeong <eric.jeong.opensource@diasemi.com> Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/regulator/pv88090-regulator.c')
-rw-r--r--drivers/regulator/pv88090-regulator.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/drivers/regulator/pv88090-regulator.c b/drivers/regulator/pv88090-regulator.c
index ab51e254d13a..7a0c15957bd0 100644
--- a/drivers/regulator/pv88090-regulator.c
+++ b/drivers/regulator/pv88090-regulator.c
@@ -43,7 +43,7 @@ enum {
struct pv88090_regulator {
struct regulator_desc desc;
/* Current limiting */
- unsigned n_current_limits;
+ unsigned int n_current_limits;
const int *current_limits;
unsigned int limit_mask;
unsigned int conf;
@@ -398,9 +398,14 @@ static int pv88090_i2c_probe(struct i2c_client *i2c,
return ret;
range = (range >>
- (PV88080_BUCK_VRANGE_GAIN_SHIFT + i - 1)) &
- PV88080_BUCK_VRANGE_GAIN_MASK;
+ (PV88090_BUCK_VRANGE_GAIN_SHIFT + i - 1)) &
+ PV88090_BUCK_VRANGE_GAIN_MASK;
index = ((range << 1) | conf2);
+ if (index > PV88090_ID_BUCK3) {
+ dev_err(chip->dev,
+ "Invalid index(%d)\n", index);
+ return -EINVAL;
+ }
pv88090_regulator_info[i].desc.min_uV
= pv88090_buck_vol[index].min_uV;