Skip to contentSkip to conversation

net/mlx5: Fix eswitch offloads cleanup on QoS init failure

PATCH In review Prathamesh Deshpande 2 participants 2 messages Apr 25 – Apr 28

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/mlx5: Fix eswitch offloads cleanup on QoS init failure

If mlx5_esw_qos_init() fails after esw_offloads_init() succeeds, mlx5_eswitch_init() jumps to reps_err and skips esw_offloads_cleanup(), leaking the offloads initialization state.

Add a dedicated unwind label for QoS init failure that cleans up offloads before continuing the existing vport and outer eswitch cleanup.

Fixes cac7356c653d ("net/mlx5: Rework esw qos domain init and cleanup")
---
 drivers/net/ethernet/mellanox/mlx5/core/eswitch.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c +3 -1
index 123c96716a54..db4bf17d2640 100644
@@ -2059,7 +2059,7 @@ int mlx5_eswitch_init(struct mlx5_core_dev *dev)
 	esw->mode = MLX5_ESWITCH_LEGACY;
 	err = mlx5_esw_qos_init(esw);
 	if (err)
-		goto reps_err;
+		goto qos_err;
 
 	mutex_init(&esw->offloads.encap_tbl_lock);
 	hash_init(esw->offloads.encap_tbl);
@@ -2088,6 +2088,8 @@ int mlx5_eswitch_init(struct mlx5_core_dev *dev)
 		 MLX5_MAX_MC_PER_VPORT(dev));
 	return 0;
 
+qos_err:
+	esw_offloads_cleanup(esw);
 reps_err:
 	mlx5_esw_vports_cleanup(esw);
 	dev->priv.eswitch = NULL;
Signature · 1 line
2.43.0
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Prathamesh Deshpande

If mlx5_esw_qos_init() fails after esw_offloads_init() succeeds, mlx5_eswitch_init() jumps to reps_err and skips esw_offloads_cleanup(), leaking the offloads initialization state.

Add a dedicated unwind label for QoS init failure that cleans up offloads before continuing the existing vport and outer eswitch cleanup.

Fixes cac7356c653d ("net/mlx5: Rework esw qos domain init and cleanup")