]> git.baikalelectronics.ru Git - kernel.git/commit
power: supply: z2_battery: Fix possible memleak in z2_batt_probe()
authorZhang Qilong <zhangqilong3@huawei.com>
Mon, 21 Nov 2022 01:18:31 +0000 (09:18 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 31 Dec 2022 12:32:44 +0000 (13:32 +0100)
commit151d2bc15dc804da54677dfeeff209a3de587e73
tree89318c964d4ed2c5bf1748e4c83816f497a07c45
parent81d14acfe188559224e235fe8dc30a57fa9411a8
power: supply: z2_battery: Fix possible memleak in z2_batt_probe()

[ Upstream commit 8a89b3d5bcbad5da817f3319372852ec564b44cc ]

If devm_gpiod_get_optional() returns error, the charger should be
freed before z2_batt_probe returns according to the context. We
fix it by just gotoing to 'err' branch.

Fixes: 2f6af7e9a665 ("power: supply: z2_battery: Convert to GPIO descriptors")
Signed-off-by: Zhang Qilong <zhangqilong3@huawei.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/power/supply/z2_battery.c