From: Ma Ke <make24@iscas.ac.cn>
To: shubhrajyoti.datta@amd.com, sai.krishna.potthuri@amd.com,
bp@alien8.de, tony.luck@intel.com, james.morse@arm.com,
mchehab@kernel.org, rric@kernel.org
Cc: linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org,
Ma Ke <make24@iscas.ac.cn>
Subject: [PATCH v2] EDAC/versal: Fix possible null pointer dereference in emif_get_id()
Date: Wed, 10 Jul 2024 09:07:46 +0800 [thread overview]
Message-ID: <20240710010746.1741228-1-make24@iscas.ac.cn> (raw)
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
next reply other threads:[~2024-07-10 1:08 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-10 1:07 Ma Ke [this message]
2024-07-10 9:16 ` Markus Elfring
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240710010746.1741228-1-make24@iscas.ac.cn \
--to=make24@iscas.ac.cn \
--cc=bp@alien8.de \
--cc=james.morse@arm.com \
--cc=linux-edac@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=rric@kernel.org \
--cc=sai.krishna.potthuri@amd.com \
--cc=shubhrajyoti.datta@amd.com \
--cc=tony.luck@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®