Commit 6f12e46e authored by Kangjie Lu's avatar Kangjie Lu Committed by Sebastian Reichel

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: default avatarKangjie Lu <kjlu@umn.edu>
Signed-off-by: default avatarSebastian Reichel <sebastian.reichel@collabora.com>
parent 3dcdb689
...@@ -809,7 +809,9 @@ static int twl4030_bci_get_property(struct power_supply *psy, ...@@ -809,7 +809,9 @@ static int twl4030_bci_get_property(struct power_supply *psy,
is_charging = state & TWL4030_MSTATEC_AC; is_charging = state & TWL4030_MSTATEC_AC;
if (!is_charging) { if (!is_charging) {
u8 s; 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) if (psy->desc->type == POWER_SUPPLY_TYPE_USB)
is_charging = s & 1; is_charging = s & 1;
else else
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment