]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
regulator: pfuze100-regulator: Variable "val" in pfuze100_regulator_probe() could...
authorYizhuo <yzhai003@ucr.edu>
Sun, 29 Sep 2019 17:09:57 +0000 (10:09 -0700)
committerStefan Bader <stefan.bader@canonical.com>
Tue, 26 Nov 2019 12:15:55 +0000 (13:15 +0100)
BugLink: https://bugs.launchpad.net/bugs/1853208
[ 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>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
drivers/regulator/pfuze100-regulator.c

index 659e516455bee1f14f50a1f60ad13b590375e5a7..4f205366d8aeab3b287d961f9e0754cca8b115b9 100644 (file)
@@ -632,7 +632,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) {
                                        desc->volt_table = pfuze3000_sw2hi;