public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Krzysztof Kozlowski <krzk@kernel.org>
To: Henry Martin <bsdhenrymartin@gmail.com>, gregkh@linuxfoundation.org
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] uio: uio_fsl_elbc_gpcm: Add NULL check in the uio_fsl_elbc_gpcm_probe
Date: Mon, 31 Mar 2025 13:39:21 +0200	[thread overview]
Message-ID: <0b99b7e5-a035-4a15-8389-dcb3ca81f96d@kernel.org> (raw)
In-Reply-To: <20250331092712.7227-1-bsdhenrymartin@gmail.com>

On 31/03/2025 11:27, Henry Martin wrote:
> When devm_kasprintf() fails, it returns a NULL pointer. However, this return value is not properly checked in the function uio_fsl_elbc_gpcm_probe.
> 
> A NULL check should be added after the devm_kasprintf() to prevent potential NULL pointer dereference error.
> 
> Fixes: d57801c45f53e ("uio: uio_fsl_elbc_gpcm: use device-managed allocators")
> 


Same comments as for other patches.

> Signed-off-by: Henry Martin <bsdhenrymartin@gmail.com>
> ---
>  drivers/uio/uio_fsl_elbc_gpcm.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/uio/uio_fsl_elbc_gpcm.c b/drivers/uio/uio_fsl_elbc_gpcm.c
> index 81454c3e2484..59ba1a2dcfe3 100644
> --- a/drivers/uio/uio_fsl_elbc_gpcm.c
> +++ b/drivers/uio/uio_fsl_elbc_gpcm.c
> @@ -384,6 +384,10 @@ static int uio_fsl_elbc_gpcm_probe(struct platform_device *pdev)
>  
>  	/* set all UIO data */
>  	info->mem[0].name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "%pOFn", node);
> +	if (!info->mem[0].name) {
> +		dev_err(priv->dev, "devm_kasprintf failed for region name\n");


There is never a printk after memory allocation failure.

Also, just like in some of the other patches, you did not really analyze
the code - you leak here resource map. Just look at the entire code
instead of blindly pasting the same code here and there.

Best regards,
Krzysztof

  reply	other threads:[~2025-03-31 11:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-31  9:27 [PATCH] uio: uio_fsl_elbc_gpcm: Add NULL check in the uio_fsl_elbc_gpcm_probe Henry Martin
2025-03-31 11:39 ` Krzysztof Kozlowski [this message]
2025-04-01 10:02   ` [PATCH v2] uio: uio_fsl_elbc_gpcm: Add NULL check in the uio_fsl_elbc_gpcm_probe() Henry Martin
2025-04-01 10:04     ` 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=0b99b7e5-a035-4a15-8389-dcb3ca81f96d@kernel.org \
    --to=krzk@kernel.org \
    --cc=bsdhenrymartin@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --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