mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] EDAC/altera: Fix possible null pointer dereference
@ 2024-07-09 13:37 Ma Ke
  2024-07-09 14:24 ` Markus Elfring
  0 siblings, 1 reply; 2+ messages in thread
From: Ma Ke @ 2024-07-09 13:37 UTC (permalink / raw)
  To: dinguyen, bp, tony.luck, james.morse, mchehab, rric, niravkumar.l.rabara
  Cc: linux-edac, linux-kernel, Ma Ke, stable

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

Cc: stable@vger.kernel.org
Fixes: e1bca853dddc ("EDAC/altera: Add SDRAM ECC check for U-Boot")
Signed-off-by: Ma Ke <make24@iscas.ac.cn>
---
 drivers/edac/altera_edac.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/edac/altera_edac.c b/drivers/edac/altera_edac.c
index fe89f5c4837f..d6bf0eebeb41 100644
--- a/drivers/edac/altera_edac.c
+++ b/drivers/edac/altera_edac.c
@@ -1086,6 +1086,7 @@ static int altr_s10_sdram_check_ecc_deps(struct altr_edac_device_dev *device)
 	struct arm_smccc_res result;
 	struct device_node *np;
 	phys_addr_t sdram_addr;
+	const __be32 *sdram_addrp;
 	u32 read_reg;
 	int ret;
 
@@ -1093,8 +1094,14 @@ static int altr_s10_sdram_check_ecc_deps(struct altr_edac_device_dev *device)
 	if (!np)
 		goto sdram_err;
 
-	sdram_addr = of_translate_address(np, of_get_address(np, 0,
-							     NULL, NULL));
+	sdram_addrp = of_get_address(np, 0, NULL, NULL);
+	if (!sdram_addrp)
+		return -EINVAL;
+
+	sdram_addr = of_translate_address(np, sdram_addrp);
+	if (!sdram_addr)
+		return -EINVAL;
+
 	of_node_put(np);
 	sdram_ecc_addr = (unsigned long)sdram_addr + prv->ecc_en_ofst;
 	arm_smccc_smc(INTEL_SIP_SMC_REG_READ, sdram_ecc_addr,
-- 
2.25.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] EDAC/altera: Fix possible null pointer dereference
  2024-07-09 13:37 [PATCH] EDAC/altera: Fix possible null pointer dereference Ma Ke
@ 2024-07-09 14:24 ` Markus Elfring
  0 siblings, 0 replies; 2+ messages in thread
From: Markus Elfring @ 2024-07-09 14:24 UTC (permalink / raw)
  To: make24, linux-edac, kernel-janitors
  Cc: stable, LKML, Borislav Petkov, Dinh Nguyen, James Morse,
	Mauro Carvalho Chehab, Niravkumar L Rabara, Robert Richter,
	Tony Luck, Wei Liu

> Signed-off-by: Ma Ke <make24@iscas.ac.cn>

Under which circumstances will this information be corrected anyhow?

The usage of mailing list addresses is probably undesirable for
the Developer's Certificate of Origin, isn't it?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.10-rc7#n398

Regards,
Markus

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-07-09 14:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-07-09 13:37 [PATCH] EDAC/altera: Fix possible null pointer dereference Ma Ke
2024-07-09 14:24 ` Markus Elfring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®