summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVladimir Oltean <vladimir.oltean@nxp.com>2026-01-21 00:10:39 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2026-01-30 12:28:43 +0300
commitac42e52979fbf052b79c94e59916dd4caf9cb555 (patch)
treeb5c95f9f43236f0761f72793c3b8a51aff9892a0
parentbc3c8d2493c6f4d2038844dc8b7ee93de050f7fa (diff)
downloadlinux-ac42e52979fbf052b79c94e59916dd4caf9cb555.tar.xz
net: dsa: fix off-by-one in maximum bridge ID determination
[ Upstream commit dfca045cd4d0ea07ff4198ba392be3e718acaddc ] Prior to the blamed commit, the bridge_num range was from 0 to ds->max_num_bridges - 1. After the commit, it is from 1 to ds->max_num_bridges. So this check: if (bridge_num >= max) return 0; must be updated to: if (bridge_num > max) return 0; in order to allow the last bridge_num value (==max) to be used. This is easiest visible when a driver sets ds->max_num_bridges=1. The observed behaviour is that even the first created bridge triggers the netlink extack "Range of offloadable bridges exceeded" warning, and is handled in software rather than being offloaded. Fixes: 3f9bb0301d50 ("net: dsa: make dp->bridge_num one-based") Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com> Link: https://patch.msgid.link/20260120211039.3228999-1-vladimir.oltean@nxp.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--net/dsa/dsa.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
index 97599e0d5a1d..76a086e846c4 100644
--- a/net/dsa/dsa.c
+++ b/net/dsa/dsa.c
@@ -157,7 +157,7 @@ unsigned int dsa_bridge_num_get(const struct net_device *bridge_dev, int max)
bridge_num = find_next_zero_bit(&dsa_fwd_offloading_bridges,
DSA_MAX_NUM_OFFLOADING_BRIDGES,
1);
- if (bridge_num >= max)
+ if (bridge_num > max)
return 0;
set_bit(bridge_num, &dsa_fwd_offloading_bridges);