mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Charles Han <hanchunchao@inspur.com>
Cc: arnd@arndb.de, jpanis@baylibre.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] misc: tps6594-pfsm: Add NULL check in tps6594_pfsm_probe
Date: Thu, 10 Apr 2025 13:50:06 +0200	[thread overview]
Message-ID: <2025041049-pushing-paced-3a3e@gregkh> (raw)
In-Reply-To: <20250410105256.70310-1-hanchunchao@inspur.com>

On Thu, Apr 10, 2025 at 06:52:53PM +0800, Charles Han wrote:
> devm_kasprintf() can return a NULL pointer on failure,but this
> returned value in tps6594_pfsm_probe() is not checked.
> Add NULL check in tps6594_pfsm_probe(), to handle kernel NULL
> pointer dereference error.
> 
> Fixes: a0df3ef087f8 ("misc: tps6594-pfsm: Add driver for TI TPS6594 PFSM")
> Signed-off-by: Charles Han <hanchunchao@inspur.com>
> ---
>  drivers/misc/tps6594-pfsm.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/misc/tps6594-pfsm.c b/drivers/misc/tps6594-pfsm.c
> index 0a24ce44cc37..05c4e081a8d2 100644
> --- a/drivers/misc/tps6594-pfsm.c
> +++ b/drivers/misc/tps6594-pfsm.c
> @@ -281,6 +281,11 @@ static int tps6594_pfsm_probe(struct platform_device *pdev)
>  	pfsm->miscdev.minor = MISC_DYNAMIC_MINOR;
>  	pfsm->miscdev.name = devm_kasprintf(dev, GFP_KERNEL, "pfsm-%ld-0x%02x",
>  					    tps->chip_id, tps->reg);
> +	if (!pfsm->miscdev.name) {
> +		devm_kfree(dev, pfsm);
> +		return -ENOMEM;
> +	}

How was this found and tested?

thanks,

greg k-h

  parent reply	other threads:[~2025-04-10 11:51 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-10 10:52 Charles Han
2025-04-10 10:56 ` Arnd Bergmann
2025-04-10 11:50 ` Greg KH [this message]
2025-04-10 11:50 ` Greg KH

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=2025041049-pushing-paced-3a3e@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=arnd@arndb.de \
    --cc=hanchunchao@inspur.com \
    --cc=jpanis@baylibre.com \
    --cc=linux-kernel@vger.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®