[PATCH net v1] net/mlx5: Fix eswitch offloads cleanup on QoS init failure
From: Prathamesh Deshpande
Date: Fri Apr 24 2026 - 20:31:54 EST
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")
Signed-off-by: Prathamesh Deshpande <prathameshdeshpande7@xxxxxxxxx>
---
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
index 123c96716a54..db4bf17d2640 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
@@ -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;
--
2.43.0