From: Krzysztof Kozlowski <krzk@kernel.org>
To: Charles Han <hanchunchao@inspur.com>,
sre@kernel.org, akpm@linux-foundation.org, lee@kernel.org
Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH V2] charger: max14577: Handle NULL pdata when CONFIG_OF is not set
Date: Mon, 19 May 2025 07:51:57 +0200 [thread overview]
Message-ID: <12523bd9-0c04-4d63-9f0e-014f14d359c2@kernel.org> (raw)
In-Reply-To: <20250519014804.2244-1-hanchunchao@inspur.com>
On 19/05/2025 03:48, Charles Han wrote:
> 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, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/power/supply/max14577_charger.c b/drivers/power/supply/max14577_charger.c
> index 1cef2f860b5f..af1694cac5ea 100644
> --- a/drivers/power/supply/max14577_charger.c
> +++ b/drivers/power/supply/max14577_charger.c
> @@ -501,7 +501,7 @@ static struct max14577_charger_platform_data *max14577_charger_dt_init(
> static struct max14577_charger_platform_data *max14577_charger_dt_init(
> struct platform_device *pdev)
> {
> - return NULL;
> + return -ENODATA;
No, you did not test it and it is obviously buggy code. Please learn
first about pointers.
Best regards,
Krzysztof
next prev parent reply other threads:[~2025-05-19 5:52 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-16 9:53 [PATCH] " 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 [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=12523bd9-0c04-4d63-9f0e-014f14d359c2@kernel.org \
--to=krzk@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=hanchunchao@inspur.com \
--cc=lee@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=sre@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®