* [PATCH v2] EDAC/versal: Fix possible null pointer dereference in emif_get_id()
@ 2024-07-10 1:07 Ma Ke
2024-07-10 9:16 ` Markus Elfring
0 siblings, 1 reply; 2+ messages in thread
From: Ma Ke @ 2024-07-10 1:07 UTC (permalink / raw)
To: shubhrajyoti.datta, sai.krishna.potthuri, bp, tony.luck,
james.morse, mchehab, rric
Cc: linux-edac, linux-kernel, Ma Ke
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@iscas.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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] EDAC/versal: Fix possible null pointer dereference in emif_get_id()
2024-07-10 1:07 [PATCH v2] EDAC/versal: Fix possible null pointer dereference in emif_get_id() Ma Ke
@ 2024-07-10 9:16 ` Markus Elfring
0 siblings, 0 replies; 2+ messages in thread
From: Markus Elfring @ 2024-07-10 9:16 UTC (permalink / raw)
To: make24, linux-edac, kernel-janitors
Cc: LKML, Borislav Petkov, James Morse, Mauro Carvalho Chehab,
Robert Richter, Sai Krishna Potthuri, Shubhrajyoti Datta,
Tony Luck, Wei Liu
…
> Signed-off-by: Ma Ke <make24@iscas.ac.cn>
Do you care for the applicability of the available information
according to this tag?
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-10 9:17 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-10 1:07 [PATCH v2] EDAC/versal: Fix possible null pointer dereference in emif_get_id() Ma Ke
2024-07-10 9:16 ` Markus Elfring
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox