summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYizhuo <yzhai003@ucr.edu>2019-09-29 10:09:57 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-11-10 11:27:15 +0100
commitbab5c14b5c8909d80a7e322613405451b25b11aa (patch)
treee58bf734cb0de904fa528b645b69cd468eb96e1d
parent6ef17b446081f41be552991b49c78d980f961a42 (diff)
downloadlinux-stable-bab5c14b5c8909d80a7e322613405451b25b11aa.tar.gz
linux-stable-bab5c14b5c8909d80a7e322613405451b25b11aa.tar.bz2
linux-stable-bab5c14b5c8909d80a7e322613405451b25b11aa.zip
regulator: pfuze100-regulator: Variable "val" in pfuze100_regulator_probe() could be uninitialized
[ Upstream commit 1252b283141f03c3dffd139292c862cae10e174d ] 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: Yizhuo <yzhai003@ucr.edu> Link: https://lore.kernel.org/r/20190929170957.14775-1-yzhai003@ucr.edu Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--drivers/regulator/pfuze100-regulator.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/drivers/regulator/pfuze100-regulator.c b/drivers/regulator/pfuze100-regulator.c
index 31c3a236120a..69a377ab2604 100644
--- a/drivers/regulator/pfuze100-regulator.c
+++ b/drivers/regulator/pfuze100-regulator.c
@@ -710,7 +710,13 @@ static int pfuze100_regulator_probe(struct i2c_client *client,
/* SW2~SW4 high bit check and modify the voltage value table */
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 (pfuze_chip->chip_id == PFUZE3000 ||
pfuze_chip->chip_id == PFUZE3001) {