From: Dinh Nguyen <dinguyen@kernel.org>
To: bp@alien8.de, tony.luck@intel.com
Cc: dinguyen@kernel.org, rounakdas2025@gmail.com,
niravkumar.l.rabara@altera.com, linux-edac@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH 1/1] EDAC/altera: Guard against NULL of_node pointer dereference
Date: Thu, 6 Aug 2026 11:10:55 -0500 [thread overview]
Message-ID: <20260806161055.1520446-2-dinguyen@kernel.org> (raw)
In-Reply-To: <20260806161055.1520446-1-dinguyen@kernel.org>
There are many sashiko reports on this driver because it is using an
unusually high amount of functions that dereference an of_node pointer.
While you can guard the NULL pointer dereference in every function, it
would be much simpler to guard it during probe functions. This edac driver
is static, meaning it cannot add/remove nodes during runtime.
So it's best to use dev_of_node() in the probe functions, so if the of_node
is NULL, the driver would simply fail to load.
Closes: https://sashiko.dev/#/patchset/20260719211238.589402-1-rosenp%40gmail.com
Signed-off-by: Dinh Nguyen <dinguyen@kernel.org>
---
drivers/edac/altera_edac.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/drivers/edac/altera_edac.c b/drivers/edac/altera_edac.c
index 68846f583eeef..f449bd45c5098 100644
--- a/drivers/edac/altera_edac.c
+++ b/drivers/edac/altera_edac.c
@@ -290,7 +290,7 @@ static int altr_sdram_probe(struct platform_device *pdev)
unsigned long mem_size, irqflags = 0;
/* Grab the register range from the sdr controller in device tree */
- mc_vbase = syscon_regmap_lookup_by_phandle(pdev->dev.of_node,
+ mc_vbase = syscon_regmap_lookup_by_phandle(dev_of_node(&pdev->dev),
"altr,sdr-syscon");
if (IS_ERR(mc_vbase)) {
edac_printk(KERN_ERR, EDAC_MC,
@@ -507,9 +507,12 @@ MODULE_DEVICE_TABLE(of, altr_edac_of_match);
static int altr_edac_probe(struct platform_device *pdev)
{
- of_platform_populate(pdev->dev.of_node, altr_edac_device_of_match,
- NULL, &pdev->dev);
- return 0;
+ int ret;
+
+ ret = of_platform_populate(dev_of_node(&pdev->dev), altr_edac_device_of_match,
+ NULL, &pdev->dev);
+
+ return ret;
}
static struct platform_driver altr_edac_driver = {
@@ -2184,7 +2187,7 @@ static int altr_edac_a10_probe(struct platform_device *pdev)
altr_edac_a10_irq_handler, edac);
}
- for_each_child_of_node(pdev->dev.of_node, child) {
+ for_each_child_of_node(dev_of_node(&pdev->dev), child) {
if (!of_device_is_available(child))
continue;
@@ -2193,7 +2196,7 @@ static int altr_edac_a10_probe(struct platform_device *pdev)
#ifdef CONFIG_EDAC_ALTERA_SDRAM
else if (of_device_is_compatible(child, "altr,sdram-edac-a10"))
- of_platform_populate(pdev->dev.of_node,
+ of_platform_populate(dev_of_node(&pdev->dev),
altr_sdram_ctrl_of_match,
NULL, &pdev->dev);
#endif
--
2.42.0.411.g813d9a9188
next prev parent reply other threads:[~2026-08-06 16:11 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-06 16:10 [PATCH 0/1] EDAC/altera: Guard against NULL of_node Dinh Nguyen
2026-08-06 16:10 ` Dinh Nguyen [this message]
2026-08-06 18:16 ` Borislav Petkov
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=20260806161055.1520446-2-dinguyen@kernel.org \
--to=dinguyen@kernel.org \
--cc=bp@alien8.de \
--cc=linux-edac@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=niravkumar.l.rabara@altera.com \
--cc=rounakdas2025@gmail.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