Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

power: supply: max14577: Handle NULL pdata when CONFIG_OF is not set

When the kernel is not configured CONFIG_OF, the max14577_charger_dt_init
function returns NULL. Fix the max14577_charger_probe functionby returning
-ENODATA instead of potentially passing a NULL pointer to PTR_ERR.

This fixes the below smatch warning:
max14577_charger_probe() warn: passing zero to 'PTR_ERR'

Fixes: e30110e9c96f ("charger: max14577: Configure battery-dependent settings from DTS and sysfs")
Signed-off-by: Charles Han <hanchunchao@inspur.com>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20250519061601.8755-1-hanchunchao@inspur.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>

authored by

Charles Han and committed by
Sebastian Reichel
2937f5d2 a9aece5d

+2 -2
+2 -2
drivers/power/supply/max14577_charger.c
··· 501 501 static struct max14577_charger_platform_data *max14577_charger_dt_init( 502 502 struct platform_device *pdev) 503 503 { 504 - return NULL; 504 + return ERR_PTR(-ENODATA); 505 505 } 506 506 #endif /* CONFIG_OF */ 507 507 ··· 572 572 chg->max14577 = max14577; 573 573 574 574 chg->pdata = max14577_charger_dt_init(pdev); 575 - if (IS_ERR_OR_NULL(chg->pdata)) 575 + if (IS_ERR(chg->pdata)) 576 576 return PTR_ERR(chg->pdata); 577 577 578 578 ret = max14577_charger_reg_init(chg);