lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250401100240.24439-1-bsdhenrymartin@gmail.com>
Date: Tue,  1 Apr 2025 18:02:40 +0800
From: Henry Martin <bsdhenrymartin@...il.com>
To: krzk@...nel.org
Cc: gregkh@...uxfoundation.org,
	linux-kernel@...r.kernel.org,
	Henry Martin <bsdhenrymartin@...il.com>
Subject: [PATCH v2] uio: uio_fsl_elbc_gpcm: Add NULL check in the uio_fsl_elbc_gpcm_probe()

devm_kasprintf() returns NULL when memory allocation fails. Currently,
uio_fsl_elbc_gpcm_probe() does not check for this case, which results in
a NULL pointer dereference.

Add NULL check after devm_kasprintf() to prevent this issue and ensuring
no resources are left allocated.

Fixes: d57801c45f53 ("uio: uio_fsl_elbc_gpcm: use device-managed allocators")
Signed-off-by: Henry Martin <bsdhenrymartin@...il.com>
---
V1 -> V2: Remove printk after memory failure and add proper resource
cleanup.

 drivers/uio/uio_fsl_elbc_gpcm.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/uio/uio_fsl_elbc_gpcm.c b/drivers/uio/uio_fsl_elbc_gpcm.c
index 81454c3e2484..26be556d956c 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) {
+		ret = -ENOMEM;
+		goto out_err3;
+	}
 	info->mem[0].addr = res.start;
 	info->mem[0].size = resource_size(&res);
 	info->mem[0].memtype = UIO_MEM_PHYS;
@@ -423,6 +427,7 @@ static int uio_fsl_elbc_gpcm_probe(struct platform_device *pdev)
 out_err2:
 	if (priv->shutdown)
 		priv->shutdown(info, true);
+out_err3:
 	iounmap(info->mem[0].internal_addr);
 	return ret;
 }
-- 
2.34.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ