]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
power: supply: cpcap-charger: Fix null check for power_supply_get_by_name
authorCharles Han <hanchunchao@inspur.com>
Mon, 19 May 2025 02:47:41 +0000 (10:47 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 15 Aug 2025 10:05:01 +0000 (12:05 +0200)
commita2436263144980cc99a9860c7b43335847afbe53
tree895b5d9e608f4065ca1ceaea4209d9101c1c1d4d
parent88bd875b7f9c3652c27d6e4bb7a23701b764f762
power: supply: cpcap-charger: Fix null check for power_supply_get_by_name

[ Upstream commit d9fa3aae08f99493e67fb79413c0e95d30fca5e9 ]

In the cpcap_usb_detect() function, the power_supply_get_by_name()
function may return `NULL` instead of an error pointer.
To prevent potential null pointer dereferences, Added a null check.

Fixes: eab4e6d953c1 ("power: supply: cpcap-charger: get the battery inserted infomation from cpcap-battery")
Signed-off-by: Charles Han <hanchunchao@inspur.com>
Link: https://lore.kernel.org/r/20250519024741.5846-1-hanchunchao@inspur.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/power/supply/cpcap-charger.c