diff options
author | Kangjie Lu <kjlu@umn.edu> | 2018-12-20 13:51:24 -0600 |
---|---|---|
committer | Sebastian Reichel <sebastian.reichel@collabora.com> | 2019-01-20 22:38:35 +0100 |
commit | 6f12e46eebf1a7d4fdd66df5e815df96b8f8b1b5 (patch) | |
tree | 3ab79ed9bac528edf0c60f0f97fd6bf6d74e9611 /drivers/power | |
parent | 3dcdb68925b82a9fe89b28bd66a8c12d8c3804a0 (diff) | |
download | linux-6f12e46eebf1a7d4fdd66df5e815df96b8f8b1b5.tar.bz2 |
power: twl4030: fix a missing check of return value
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>
Diffstat (limited to 'drivers/power')
-rw-r--r-- | drivers/power/supply/twl4030_charger.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/power/supply/twl4030_charger.c b/drivers/power/supply/twl4030_charger.c index 0e202d4273fb..4299873a1118 100644 --- a/drivers/power/supply/twl4030_charger.c +++ b/drivers/power/supply/twl4030_charger.c @@ -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 |