[PATCH] net: dsa: don't index the port array one entry past its end
Ahmad Fatoum
a.fatoum at pengutronix.de
Wed Aug 26 02:58:42 PDT 2026
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 at 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
More information about the barebox
mailing list