mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] net: dsa: don't index the port array one entry past its end
@ 2026-08-26  9:58 Ahmad Fatoum
  2026-08-28 12:17 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Ahmad Fatoum @ 2026-08-26  9:58 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

dsa_rx_preprocessor() takes the source port out of the received frame
and rejects it with

	if (port > DSA_MAX_PORTS)
		return -ERANGE;

before reading ds->dp[port], but the array is declared as

	struct dsa_port *dp[DSA_MAX_PORTS];

so the last accepted value indexes one entry past its end.

Fix this off-by-one.

Fixes: d64486483505 ("net: add DSA framework to support basic switch functionality")
Assisted-by: Claude:opus-5
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 drivers/net/dsa.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/dsa.c b/drivers/net/dsa.c
index 8eb12522999f..7b2de7324e4a 100644
--- a/drivers/net/dsa.c
+++ b/drivers/net/dsa.c
@@ -311,7 +311,7 @@ static int dsa_rx_preprocessor(struct eth_device *edev, unsigned char **packet,
 	*packet += ds->needed_headroom;
 	*length -= ds->needed_rx_tailroom;
 
-	if (port > DSA_MAX_PORTS)
+	if (port >= DSA_MAX_PORTS)
 		return -ERANGE;
 
 	dp = ds->dp[port];
-- 
2.47.3




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-08-28 12:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-26  9:58 [PATCH] net: dsa: don't index the port array one entry past its end Ahmad Fatoum
2026-08-28 12:17 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox