Re: [PATCH] uio: uio_fsl_elbc_gpcm: Add NULL check in the uio_fsl_elbc_gpcm_probe

From: Krzysztof Kozlowski
Date: Mon Mar 31 2025 - 07:39:30 EST


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@xxxxxxxxx>
> ---
> 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