Commit 1252b283 authored by Yizhuo's avatar Yizhuo Committed by Mark Brown

regulator: pfuze100-regulator: Variable "val" in pfuze100_regulator_probe() could be uninitialized

In function pfuze100_regulator_probe(), variable "val" could be
initialized if regmap_read() fails. However, "val" is used to
decide the control flow later in the if statement, which is
potentially unsafe.
Signed-off-by: default avatarYizhuo <yzhai003@ucr.edu>
Link: https://lore.kernel.org/r/20190929170957.14775-1-yzhai003@ucr.eduSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent f75841aa
...@@ -788,7 +788,13 @@ static int pfuze100_regulator_probe(struct i2c_client *client, ...@@ -788,7 +788,13 @@ static int pfuze100_regulator_probe(struct i2c_client *client,
/* SW2~SW4 high bit check and modify the voltage value table */ /* SW2~SW4 high bit check and modify the voltage value table */
if (i >= sw_check_start && i <= sw_check_end) { if (i >= sw_check_start && i <= sw_check_end) {
regmap_read(pfuze_chip->regmap, desc->vsel_reg, &val); ret = regmap_read(pfuze_chip->regmap,
desc->vsel_reg, &val);
if (ret) {
dev_err(&client->dev, "Fails to read from the register.\n");
return ret;
}
if (val & sw_hi) { if (val & sw_hi) {
if (pfuze_chip->chip_id == PFUZE3000 || if (pfuze_chip->chip_id == PFUZE3000 ||
pfuze_chip->chip_id == PFUZE3001) { pfuze_chip->chip_id == PFUZE3001) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment