]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
power: twl4030: fix a missing check of return value
authorKangjie Lu <kjlu@umn.edu>
Thu, 20 Dec 2018 19:51:24 +0000 (13:51 -0600)
committerSebastian Reichel <sebastian.reichel@collabora.com>
Sun, 20 Jan 2019 21:38:35 +0000 (22:38 +0100)
If twl4030_bci_read() fails, the read data in "s" is incorrect,
which is however used in the following execution. The fix checks
the return value of twl4030_bci_read() and returns an error code
upstream upon the failure of twl4030_bci_read().

Signed-off-by: Kangjie Lu <kjlu@umn.edu>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
drivers/power/supply/twl4030_charger.c

index 0e202d4273fb627f671af379f591bdabbcae297b..4299873a11188249c6aebeb516a2ead6677ae06a 100644 (file)
@@ -809,7 +809,9 @@ static int twl4030_bci_get_property(struct power_supply *psy,
                is_charging = state & TWL4030_MSTATEC_AC;
        if (!is_charging) {
                u8 s;
-               twl4030_bci_read(TWL4030_BCIMDEN, &s);
+               ret = twl4030_bci_read(TWL4030_BCIMDEN, &s);
+               if (ret < 0)
+                       return ret;
                if (psy->desc->type == POWER_SUPPLY_TYPE_USB)
                        is_charging = s & 1;
                else