Skip to content

Commit 8986a11

Browse files
Eric Jeongbroonie
authored andcommitted
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 <[email protected]> Signed-off-by: Mark Brown <[email protected]>
1 parent 5771a8c commit 8986a11

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

drivers/regulator/pv88090-regulator.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ enum {
4343
struct pv88090_regulator {
4444
struct regulator_desc desc;
4545
/* Current limiting */
46-
unsigned n_current_limits;
46+
unsigned int n_current_limits;
4747
const int *current_limits;
4848
unsigned int limit_mask;
4949
unsigned int conf;
@@ -398,9 +398,14 @@ static int pv88090_i2c_probe(struct i2c_client *i2c,
398398
return ret;
399399

400400
range = (range >>
401-
(PV88080_BUCK_VRANGE_GAIN_SHIFT + i - 1)) &
402-
PV88080_BUCK_VRANGE_GAIN_MASK;
401+
(PV88090_BUCK_VRANGE_GAIN_SHIFT + i - 1)) &
402+
PV88090_BUCK_VRANGE_GAIN_MASK;
403403
index = ((range << 1) | conf2);
404+
if (index > PV88090_ID_BUCK3) {
405+
dev_err(chip->dev,
406+
"Invalid index(%d)\n", index);
407+
return -EINVAL;
408+
}
404409

405410
pv88090_regulator_info[i].desc.min_uV
406411
= pv88090_buck_vol[index].min_uV;

drivers/regulator/pv88090-regulator.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,10 @@
8989
#define PV88090_BUCK_VDAC_RANGE_2 0x01
9090

9191
/* PV88090_REG_BUCK_FOLD_RANGE (addr=0x61) */
92-
#define PV88080_BUCK_VRANGE_GAIN_SHIFT 3
93-
#define PV88080_BUCK_VRANGE_GAIN_MASK 0x01
92+
#define PV88090_BUCK_VRANGE_GAIN_SHIFT 3
93+
#define PV88090_BUCK_VRANGE_GAIN_MASK 0x01
9494

95-
#define PV88080_BUCK_VRANGE_GAIN_1 0x00
96-
#define PV88080_BUCK_VRANGE_GAIN_2 0x01
95+
#define PV88090_BUCK_VRANGE_GAIN_1 0x00
96+
#define PV88090_BUCK_VRANGE_GAIN_2 0x01
9797

9898
#endif /* __PV88090_REGISTERS_H__ */

0 commit comments

Comments
 (0)