All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] charger: max14577: Handle NULL pdata when CONFIG_OF is not set
@ 2025-05-16  9:53 Charles Han
  2025-05-16 12:32 ` Krzysztof Kozlowski
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Charles Han @ 2025-05-16  9:53 UTC (permalink / raw)
  To: krzk, sre, akpm, lee; +Cc: linux-pm, linux-kernel, Charles Han

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.

Fix below smatch warning.
smatch warnings:
drivers/power/supply/max14577_charger.c:576 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>
---
 drivers/power/supply/max14577_charger.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/power/supply/max14577_charger.c b/drivers/power/supply/max14577_charger.c
index 1cef2f860b5f..ed6f5a584c2c 100644
--- a/drivers/power/supply/max14577_charger.c
+++ b/drivers/power/supply/max14577_charger.c
@@ -572,8 +572,10 @@ static int max14577_charger_probe(struct platform_device *pdev)
 	chg->max14577 = max14577;
 
 	chg->pdata = max14577_charger_dt_init(pdev);
-	if (IS_ERR_OR_NULL(chg->pdata))
+	if (IS_ERR(chg->pdata))
 		return PTR_ERR(chg->pdata);
+	else if (!chg->pdata)
+		return -ENODATA;
 
 	ret = max14577_charger_reg_init(chg);
 	if (ret)
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2025-06-22 19:13 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-16  9:53 [PATCH] charger: max14577: Handle NULL pdata when CONFIG_OF is not set Charles Han
2025-05-16 12:32 ` Krzysztof Kozlowski
2025-05-19  1:48 ` [PATCH V2] " Charles Han
2025-05-19  5:51   ` Krzysztof Kozlowski
2025-05-19  5:58   ` kernel test robot
2025-05-19  6:16 ` [PATCH V3] " Charles Han
2025-05-19 16:20   ` Krzysztof Kozlowski
2025-06-22 19:13   ` Sebastian Reichel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.