mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
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] charger: max14577: Handle NULL pdata when CONFIG_OF is not set
Date: Fri, 16 May 2025 14:32:49 +0200	[thread overview]
Message-ID: <32290fec-72e7-44fc-a187-d29347ea94ea@kernel.org> (raw)
In-Reply-To: <20250516095346.24169-1-hanchunchao@inspur.com>

On 16/05/2025 11:53, 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, 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);

Thanks for the fix. I would prefer to fix the max14577_charger_dt_init()
stub to return ERR_PTR(-ENODATA) in such case  and then you have here
only if (IS_ERR()).

> -	if (IS_ERR_OR_NULL(chg->pdata))
Best regards,
Krzysztof

  reply	other threads:[~2025-05-16 12:32 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-16  9:53 Charles Han
2025-05-16 12:32 ` Krzysztof Kozlowski [this message]
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

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=32290fec-72e7-44fc-a187-d29347ea94ea@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®