IB/mlx5: Fix memory leak in GSI QP destroy error path
Subsystems (2)
PATCH 1/1 IB/mlx5: Fix memory leak in GSI QP destroy error path
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.
--- drivers/infiniband/hw/mlx5/gsi.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/infiniband/hw/mlx5/gsi.c +1 -3
@@ -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 ;
Signature · 1 line
2.43.0
Quoted 8 lines · Prathamesh Deshpande
In
mlx5_ib_destroy_gsi(), if the call toib_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
Quoted 2 lines · Leon Romanovsky
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