public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Prathamesh Deshpande <prathameshdeshpande7@gmail.com>
To: saeedm@nvidia.com, leon@kernel.org
Cc: kuba@kernel.org, tariqt@nvidia.com, cratiu@nvidia.com,
	cjubran@nvidia.com, netdev@vger.kernel.org,
	linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org,
	Prathamesh Deshpande <prathameshdeshpande7@gmail.com>
Subject: [PATCH net v1] net/mlx5: Fix eswitch offloads cleanup on QoS init failure
Date: Sat, 25 Apr 2026 01:29:59 +0100	[thread overview]
Message-ID: <20260425003046.6889-1-prathameshdeshpande7@gmail.com> (raw)

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@gmail.com>
---
 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


                 reply	other threads:[~2026-04-25  0:31 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260425003046.6889-1-prathameshdeshpande7@gmail.com \
    --to=prathameshdeshpande7@gmail.com \
    --cc=cjubran@nvidia.com \
    --cc=cratiu@nvidia.com \
    --cc=kuba@kernel.org \
    --cc=leon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=saeedm@nvidia.com \
    --cc=tariqt@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox