[PATCH net-next v3] mlxsw: spectrum_switchdev: fix wrong list member in flood rollback

From: Ziheng Wei

Date: Thu Dec 03 2026 - 09:41:04 EST


mlxsw_sp_bridge_vlans_flood_set() walks bridge_vlan->port_vlan_list via
mlxsw_sp_port_vlan->bridge_vlan_node, but its err_fid_flood_set rollback
path instead uses the list member in
list_for_each_entry_continue_reverse().

Because mlxsw_sp_port_vlan->list links the entry onto
mlxsw_sp_port->vlans_list rather than bridge_vlan->port_vlan_list, an
error from mlxsw_sp_fid_flood_set() causes rollback to walk unrelated
VLANs on the failing port, never match &bridge_vlan->port_vlan_list, and
treat &mlxsw_sp_port->vlans_list as a struct mlxsw_sp_port_vlan entry,
leading to an out-of-bounds pointer dereference (kernel oops) or an
infinite loop.

Use bridge_vlan_node so rollback computes the proper container address
and walks the same list as the forward loop.

Found by LLM-assisted static analysis. Compile-tested on x86_64 with
CONFIG_MLXSW_SPECTRUM=m; no hardware test.

Fixes: a6f43b1dad80 ("mlxsw: spectrum_switchdev: Simplify mlxsw_sp_port_mc_disabled_set()")
Signed-off-by: Ziheng Wei <zihengw03@xxxxxxx>
Reviewed-by: Petr Machata <petrm@xxxxxxxxxx>
---
v2 -> v3:
- Restore Fixes: tag per netdev rules (v1 review only asked to target
net-next, not to drop Fixes:) and describe the rollback failure impact
(out-of-bounds dereference / oops or infinite loop).
- v2: https://lore.kernel.org/r/20261201140545.1572541-1-zihengw03@xxxxxxx
- v1: https://lore.kernel.org/r/20261130103229.1383713-1-zihengw03@xxxxxxx

drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
index de60b698b..e54a4ec75 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
@@ -787,7 +787,7 @@ mlxsw_sp_bridge_vlans_flood_set(struct mlxsw_sp_bridge_vlan *bridge_vlan,
err_fid_flood_set:
list_for_each_entry_continue_reverse(mlxsw_sp_port_vlan,
&bridge_vlan->port_vlan_list,
- list) {
+ bridge_vlan_node) {
u16 local_port = mlxsw_sp_port_vlan->mlxsw_sp_port->local_port;

mlxsw_sp_fid_flood_set(mlxsw_sp_port_vlan->fid, packet_type,

base-commit: 97d73c8251226cf27cc6656b4c542869bb8c69fa
--
2.43.0