diff options
author | Colin Ian King <colin.king@canonical.com> | 2021-01-15 16:15:24 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2021-03-04 13:37:55 +0300 |
commit | 3f93f17ae9468fc20e9a2cdb80c461284ca4118a (patch) | |
tree | 9818f6f9d6bd7fe956a672f10effe2879b02ed41 /drivers/power | |
parent | 1f613374921326ed5c1fa89384e823447a607f78 (diff) | |
download | linux-3f93f17ae9468fc20e9a2cdb80c461284ca4118a.tar.xz |
power: supply: cpcap-charger: Fix power_supply_put on null battery pointer
[ Upstream commit 39196cfe10dd2b46ee28b44abbc0db4f4cb7822f ]
Currently if the pointer battery is null there is a null pointer
dereference on the call to power_supply_put. Fix this by only
performing the put if battery is not null.
Addresses-Coverity: ("Dereference after null check")
Fixes: 4bff91bb3231 ("power: supply: cpcap-charger: Fix missing power_supply_put()")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Acked-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/power')
-rw-r--r-- | drivers/power/supply/cpcap-charger.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/power/supply/cpcap-charger.c b/drivers/power/supply/cpcap-charger.c index 2c5f2246c6ea..22fff01425d6 100644 --- a/drivers/power/supply/cpcap-charger.c +++ b/drivers/power/supply/cpcap-charger.c @@ -301,8 +301,9 @@ cpcap_charger_get_bat_const_charge_voltage(struct cpcap_charger_ddata *ddata) &prop); if (!error) voltage = prop.intval; + + power_supply_put(battery); } - power_supply_put(battery); return voltage; } |