[PATCH 03/10] EDAC/altera: Guard against NULL match data in altr_sdram_probe()
From: Dinh Nguyen
Date: Mon Jul 27 2026 - 09:41:03 EST
sashiko reports: If a device is manually bound and lacks a valid match entry,
of_match_node() or device_get_match_data() could return NULL.
altr_sdram_probe() dereferenced the pointer returned by of_match_node()
and device_get_match_data() without checking it, which could cause a NULL
pointer dereference when no match data is found. Add a guard that logs
an error and returns -ENODEV.
Assisted-by: Cursor:claude-4.8-opus
Fixes: 143f4a5ac5af ("EDAC, altera: Refactor for Altera CycloneV SoC")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Dinh Nguyen <dinguyen@xxxxxxxxxx>
---
drivers/edac/altera_edac.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/edac/altera_edac.c b/drivers/edac/altera_edac.c
index 34b33298cf86e..8cbf71ce5d2d8 100644
--- a/drivers/edac/altera_edac.c
+++ b/drivers/edac/altera_edac.c
@@ -300,6 +300,10 @@ static int altr_sdram_probe(struct platform_device *pdev)
/* Check specific dependencies for the module */
priv = device_get_match_data(&pdev->dev);
+ if (!priv) {
+ edac_printk(KERN_ERR, EDAC_MC, "No match data found\n");
+ return -ENODEV;
+ }
/* Validate the SDRAM controller has ECC enabled */
if (regmap_read(mc_vbase, priv->ecc_ctrl_offset, &read_reg) ||
--
2.42.0.411.g813d9a9188