Skip to content

Commit 88de89f

Browse files
YanLong Dairleon
authored andcommitted
RDMA/bnxt_re: Fix a potential memory leak in destroy_gsi_sqp
The current error handling path in bnxt_re_destroy_gsi_sqp() could lead to a resource leak. When bnxt_qplib_destroy_qp() fails, the function jumps to the 'fail' label and returns immediately, skipping the call to bnxt_qplib_free_qp_res(). Continue the resource teardown even if bnxt_qplib_destroy_qp() fails, which aligns with the driver's general error handling strategy and prevents the potential leak. Fixes: 8dae419 ("RDMA/bnxt_re: Refactor queue pair creation code") Signed-off-by: YanLong Dai <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Leon Romanovsky <[email protected]>
1 parent 3a86608 commit 88de89f

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

drivers/infiniband/hw/bnxt_re/ib_verbs.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -913,7 +913,7 @@ void bnxt_re_unlock_cqs(struct bnxt_re_qp *qp,
913913
spin_unlock_irqrestore(&qp->scq->cq_lock, flags);
914914
}
915915

916-
static int bnxt_re_destroy_gsi_sqp(struct bnxt_re_qp *qp)
916+
static void bnxt_re_destroy_gsi_sqp(struct bnxt_re_qp *qp)
917917
{
918918
struct bnxt_re_qp *gsi_sqp;
919919
struct bnxt_re_ah *gsi_sah;
@@ -933,10 +933,9 @@ static int bnxt_re_destroy_gsi_sqp(struct bnxt_re_qp *qp)
933933

934934
ibdev_dbg(&rdev->ibdev, "Destroy the shadow QP\n");
935935
rc = bnxt_qplib_destroy_qp(&rdev->qplib_res, &gsi_sqp->qplib_qp);
936-
if (rc) {
936+
if (rc)
937937
ibdev_err(&rdev->ibdev, "Destroy Shadow QP failed");
938-
goto fail;
939-
}
938+
940939
bnxt_qplib_free_qp_res(&rdev->qplib_res, &gsi_sqp->qplib_qp);
941940

942941
/* remove from active qp list */
@@ -951,10 +950,6 @@ static int bnxt_re_destroy_gsi_sqp(struct bnxt_re_qp *qp)
951950
rdev->gsi_ctx.gsi_sqp = NULL;
952951
rdev->gsi_ctx.gsi_sah = NULL;
953952
rdev->gsi_ctx.sqp_tbl = NULL;
954-
955-
return 0;
956-
fail:
957-
return rc;
958953
}
959954

960955
static void bnxt_re_del_unique_gid(struct bnxt_re_dev *rdev)

0 commit comments

Comments
 (0)