Re: [PATCH] uio: uio_fsl_elbc_gpcm: Add check devm_kasprintf() returned value

From: Greg KH
Date: Sun Oct 13 2024 - 11:16:19 EST


On Sun, Sep 29, 2024 at 11:42:23AM +0800, Charles Han wrote:
> devm_kasprintf() can return a NULL pointer on failure but this
> returned value in uio_fsl_elbc_gpcm_probe() is not checked.
>
> Fixes: d57801c45f53 ("uio: uio_fsl_elbc_gpcm: use device-managed allocators")
> Signed-off-by: Charles Han <hanchunchao@xxxxxxxxxx>
> ---
> drivers/uio/uio_fsl_elbc_gpcm.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/uio/uio_fsl_elbc_gpcm.c b/drivers/uio/uio_fsl_elbc_gpcm.c
> index 496caff66e7e..6378e752f828 100644
> --- a/drivers/uio/uio_fsl_elbc_gpcm.c
> +++ b/drivers/uio/uio_fsl_elbc_gpcm.c
> @@ -384,6 +384,9 @@ 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)
> + return -ENOMEM;

This is wrong, please fix your tools that created such a patch as it now
leaks memory :(