net/mlx5: Fix eswitch offloads cleanup on QoS init failure
Subsystems (4)
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")
Signed-off-by Prathamesh Deshpande <[email protected]>
--- 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
@@ -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
Quoted 9 lines · Prathamesh Deshpande
If
mlx5_esw_qos_init()fails afteresw_offloads_init()succeeds,mlx5_eswitch_init()jumps toreps_errand skipsesw_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 <[email protected]>
Reviewed-by Simon Horman <[email protected]>