From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH] net: dsa: don't index the port array one entry past its end
Date: Wed, 26 Aug 2026 11:58:42 +0200 [thread overview]
Message-ID: <20260826095844.2666779-1-a.fatoum@pengutronix.de> (raw)
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
next reply other threads:[~2026-08-26 10:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-26 9:58 Ahmad Fatoum [this message]
2026-08-28 12:17 ` Sascha Hauer
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=20260826095844.2666779-1-a.fatoum@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
/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