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-next>] [day] [month] [year] [list]
Message-Id: <20240710010746.1741228-1-make24@iscas.ac.cn>
Date: Wed, 10 Jul 2024 09:07:46 +0800
From: Ma Ke <make24@...as.ac.cn>
To: shubhrajyoti.datta@....com,
	sai.krishna.potthuri@....com,
	bp@...en8.de,
	tony.luck@...el.com,
	james.morse@....com,
	mchehab@...nel.org,
	rric@...nel.org
Cc: linux-edac@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	Ma Ke <make24@...as.ac.cn>
Subject: [PATCH v2] EDAC/versal: Fix possible null pointer dereference in emif_get_id()

In emif_get_id(), of_get_address() may return NULL which is later
dereferenced. Fix this bug by adding NULL check.

Fixes: 6f15b178cd63 ("EDAC/versal: Add a Xilinx Versal memory controller driver")
Signed-off-by: Ma Ke <make24@...as.ac.cn>
---
Changes in v2:
- fixed the typo according to suggestions.
---
 drivers/edac/versal_edac.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/edac/versal_edac.c b/drivers/edac/versal_edac.c
index a556d23e8261..d837edac30e7 100644
--- a/drivers/edac/versal_edac.c
+++ b/drivers/edac/versal_edac.c
@@ -1053,6 +1053,9 @@ static u32 emif_get_id(struct device_node *node)
 	const __be32 *addrp;
 
 	addrp = of_get_address(node, 0, NULL, NULL);
+	if (!addrp)
+		return -EINVAL;
+
 	my_addr = (u32)of_translate_address(node, addrp);
 
 	for_each_matching_node(np, xlnx_edac_match) {
@@ -1060,6 +1063,9 @@ static u32 emif_get_id(struct device_node *node)
 			continue;
 
 		addrp = of_get_address(np, 0, NULL, NULL);
+		if (!addrp)
+			return -EINVAL;
+
 		addr = (u32)of_translate_address(np, addrp);
 
 		edac_printk(KERN_INFO, EDAC_MC,
-- 
2.25.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ