power: supply: cpcap-charger: Fix power_supply_put on null battery pointer
authorColin Ian King <colin.king@canonical.com>
Fri, 15 Jan 2021 13:15:24 +0000 (13:15 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 4 Mar 2021 10:37:55 +0000 (11:37 +0100)
commit3f93f17ae9468fc20e9a2cdb80c461284ca4118a
tree9818f6f9d6bd7fe956a672f10effe2879b02ed41
parent1f613374921326ed5c1fa89384e823447a607f78
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>
drivers/power/supply/cpcap-charger.c