Skip to contentSkip to conversation

EDAC/versalnet: Fix off by one in handle_error()

PATCH Applied Dan Carpenter 3 participants 3 messages Sep 27, 2025 – Oct 13, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 EDAC/versalnet: Fix off by one in handle_error()

The priv->mci[] array has NUM_CONTROLLERS so this > comparison needs to be >= to prevent an out of bounds access.

Fixes d5fe2fec6c40 ("EDAC: Add a driver for the AMD Versal NET DDR controller")
---
 drivers/edac/versalnet_edac.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/edac/versalnet_edac.c +1 -1
index 7c5db8bf0595..1ded4c3f0213 100644
@@ -433,7 +433,7 @@ static void handle_error(struct mc_priv  *priv, struct ecc_status *stat,
 	phys_addr_t pfn;
 	int err;
 
-	if (WARN_ON_ONCE(ctl_num > NUM_CONTROLLERS))
+	if (WARN_ON_ONCE(ctl_num >= NUM_CONTROLLERS))
 		return;
 
 	mci = priv->mci[ctl_num];
Signature · 1 line
2.51.0
maintainer Applied
#2 lore raw
In reply to Dan Carpenter
Quoted 15 lines · Dan Carpenter

The priv->mci[] array has NUM_CONTROLLERS so this > comparison needs to be >= to prevent an out of bounds access.

Fixes d5fe2fec6c40 ("EDAC: Add a driver for the AMD Versal NET DDR controller")
---
 drivers/edac/versalnet_edac.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/edac/versalnet_edac.c +0 -0
index 7c5db8bf0595..1ded4c3f0213 100644

drivers/edac/versalnet_edac.c static void handle_error(struct mc_priv *priv, struct ecc_status *stat, · line 439

Quoted 8 lines
drivers/edac/versalnet_edac.c +1 -1
@@ -433,7 +433,7 @@ static void handle_error(struct mc_priv  *priv, struct ecc_status *stat,
 	phys_addr_t pfn;
 	int err;
 
-	if (WARN_ON_ONCE(ctl_num > NUM_CONTROLLERS))
+	if (WARN_ON_ONCE(ctl_num >= NUM_CONTROLLERS))
 		return;
 
 	mci = priv->mci[ctl_num];

Applied, thanks.

Signature · 4 lines
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette