From: Prathamesh Deshpande <prathameshdeshpande7@gmail.com>
To: Leon Romanovsky <leon@kernel.org>, Jason Gunthorpe <jgg@ziepe.ca>
Cc: Haggai Eran <haggaie@mellanox.com>,
Doug Ledford <dledford@redhat.com>,
linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org,
Prathamesh Deshpande <prathameshdeshpande7@gmail.com>
Subject: [PATCH] IB/mlx5: Fix memory leak in GSI QP destroy error path
Date: Tue, 31 Mar 2026 01:48:10 +0100 [thread overview]
Message-ID: <20260331004811.8851-1-prathameshdeshpande7@gmail.com> (raw)
In mlx5_ib_destroy_gsi(), if the call to ib_destroy_qp() fails for
the hardware receive QP (gsi->rx_qp), the function currently returns
early. This results in a memory leak of the software resources
(outstanding_wrs, tx_qps) and the 'gsi' structure itself.
Align the GSI destroy path with the 'best-effort' cleanup pattern. Even
if the hardware fails to release the QP, proceed with the software
cleanup to prevent orphan allocations.
Fixes: d16e91daf446 ("IB/mlx5: Add GSI QP wrapper")
Signed-off-by: Prathamesh Deshpande <prathameshdeshpande7@gmail.com>
---
drivers/infiniband/hw/mlx5/gsi.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/infiniband/hw/mlx5/gsi.c b/drivers/infiniband/hw/mlx5/gsi.c
index b2e2a219639d..2272236e7f7f 100644
--- a/drivers/infiniband/hw/mlx5/gsi.c
+++ b/drivers/infiniband/hw/mlx5/gsi.c
@@ -175,11 +175,9 @@ int mlx5_ib_destroy_gsi(struct mlx5_ib_qp *mqp)
int ret;
ret = ib_destroy_qp(gsi->rx_qp);
- if (ret) {
+ if (ret)
mlx5_ib_warn(dev, "unable to destroy hardware GSI QP. error %d\n",
ret);
- return ret;
- }
dev->devr.ports[port_num - 1].gsi = NULL;
gsi->rx_qp = NULL;
--
2.43.0
next reply other threads:[~2026-03-31 0:49 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-31 0:48 Prathamesh Deshpande [this message]
2026-03-31 13:45 ` [PATCH] IB/mlx5: Fix memory leak in GSI QP destroy error path Leon Romanovsky
2026-03-31 18:04 ` Prathamesh Deshpande
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=20260331004811.8851-1-prathameshdeshpande7@gmail.com \
--to=prathameshdeshpande7@gmail.com \
--cc=dledford@redhat.com \
--cc=haggaie@mellanox.com \
--cc=jgg@ziepe.ca \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
/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