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:14:32 +0000 (13:14 +0100)
commita72fe8eb5555d6e80e252edeb4490f46675a0ea5
treeff09b15a93760d00c2d0b93609f50c2165b622f0
parent5ba0e8fa150c414f2d0e59908b6f9b37a3a77edb
power: supply: z2_battery: Fix possible memleak in z2_batt_probe()

[ Upstream commit 955bee204f3dd307642c101b75e370662987e735 ]

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: a3b4388ea19b ("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