public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] IB/mlx5: Fix memory leak in GSI QP destroy error path
@ 2026-03-31  0:48 Prathamesh Deshpande
  2026-03-31 13:45 ` Leon Romanovsky
  0 siblings, 1 reply; 3+ messages in thread
From: Prathamesh Deshpande @ 2026-03-31  0:48 UTC (permalink / raw)
  To: Leon Romanovsky, Jason Gunthorpe
  Cc: Haggai Eran, Doug Ledford, linux-rdma, linux-kernel,
	Prathamesh Deshpande

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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] IB/mlx5: Fix memory leak in GSI QP destroy error path
  2026-03-31  0:48 [PATCH] IB/mlx5: Fix memory leak in GSI QP destroy error path Prathamesh Deshpande
@ 2026-03-31 13:45 ` Leon Romanovsky
  2026-03-31 18:04   ` Prathamesh Deshpande
  0 siblings, 1 reply; 3+ messages in thread
From: Leon Romanovsky @ 2026-03-31 13:45 UTC (permalink / raw)
  To: Prathamesh Deshpande
  Cc: Jason Gunthorpe, Haggai Eran, Doug Ledford, linux-rdma,
	linux-kernel

On Tue, Mar 31, 2026 at 01:48:10AM +0100, Prathamesh Deshpande wrote:
> 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.

GSI QP are different from other "best-effort" failures. It MUST to fail.
We are intentionally leaking resources here.

Thanks

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] IB/mlx5: Fix memory leak in GSI QP destroy error path
  2026-03-31 13:45 ` Leon Romanovsky
@ 2026-03-31 18:04   ` Prathamesh Deshpande
  0 siblings, 0 replies; 3+ messages in thread
From: Prathamesh Deshpande @ 2026-03-31 18:04 UTC (permalink / raw)
  To: leon; +Cc: dledford, haggaie, jgg, linux-kernel, linux-rdma,
	prathameshdeshpande7

On Tue, Mar 31, 2026 at 04:45:08PM +0300, Leon Romanovsky wrote:
> GSI QP are different from other "best-effort" failures. It MUST to fail.
> We are intentionally leaking resources here.

Hi Leon,

Thank you for the explanation.

I understand now that for GSI QPs, the hardware constraints make a
memory leak preferable to the risk of an inconsistency in this
failure path.

I'll keep this in mind for future mlx5 cleanup patches.

Thanks,
Prathamesh

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-03-31 18:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-31  0:48 [PATCH] IB/mlx5: Fix memory leak in GSI QP destroy error path Prathamesh Deshpande
2026-03-31 13:45 ` Leon Romanovsky
2026-03-31 18:04   ` Prathamesh Deshpande

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox