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)
committerSebastian Reichel <sebastian.reichel@collabora.com>
Sun, 22 Jun 2025 17:23:04 +0000 (19:23 +0200)
commitd9fa3aae08f99493e67fb79413c0e95d30fca5e9
treec19c8ee6b96ca57da704718e8e1ae59dadd01b07
parent7cf88213b95e9491572c4af39c7ba2829f9b2637
power: supply: cpcap-charger: Fix null check for power_supply_get_by_name

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>
drivers/power/supply/cpcap-charger.c