Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Yizhuo <yzhai003@ucr.edu>
Link: https://lore.kernel.org/r/20190929170957.14775-1-yzhai003@ucr.edu
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Yizhuo and committed by
Mark Brown
1252b283 f75841aa

+7 -1
+7 -1
drivers/regulator/pfuze100-regulator.c
··· 788 788 789 789 /* SW2~SW4 high bit check and modify the voltage value table */ 790 790 if (i >= sw_check_start && i <= sw_check_end) { 791 - regmap_read(pfuze_chip->regmap, desc->vsel_reg, &val); 791 + ret = regmap_read(pfuze_chip->regmap, 792 + desc->vsel_reg, &val); 793 + if (ret) { 794 + dev_err(&client->dev, "Fails to read from the register.\n"); 795 + return ret; 796 + } 797 + 792 798 if (val & sw_hi) { 793 799 if (pfuze_chip->chip_id == PFUZE3000 || 794 800 pfuze_chip->chip_id == PFUZE3001) {