[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250331092712.7227-1-bsdhenrymartin@gmail.com>
Date: Mon, 31 Mar 2025 17:27:12 +0800
From: Henry Martin <bsdhenrymartin@...il.com>
To: gregkh@...uxfoundation.org
Cc: linux-kernel@...r.kernel.org,
Henry Martin <bsdhenrymartin@...il.com>
Subject: [PATCH] uio: uio_fsl_elbc_gpcm: Add NULL check in the uio_fsl_elbc_gpcm_probe
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")
Signed-off-by: Henry Martin <bsdhenrymartin@...il.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");
+ return -ENOMEM;
+ }
info->mem[0].addr = res.start;
info->mem[0].size = resource_size(&res);
info->mem[0].memtype = UIO_MEM_PHYS;
--
2.34.1
Powered by blists - more mailing lists