]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
RDMA/bnxt_re: Fix a potential memory leak in destroy_gsi_sqp
authorYanLong Dai <daiyanlong@kylinos.cn>
Wed, 24 Sep 2025 06:14:44 +0000 (14:14 +0800)
committerLeon Romanovsky <leon@kernel.org>
Sun, 19 Oct 2025 10:47:55 +0000 (06:47 -0400)
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: 8dae419f9ec73 ("RDMA/bnxt_re: Refactor queue pair creation code")
Signed-off-by: YanLong Dai <daiyanlong@kylinos.cn>
Link: https://patch.msgid.link/20250924061444.11288-1-daiyanlong@kylinos.cn
Signed-off-by: Leon Romanovsky <leon@kernel.org>
drivers/infiniband/hw/bnxt_re/ib_verbs.c

index 4dab5ca7362b56d592ad515b63fd487c8cc97507..84ce3fce2826b74230085b269117746b6867d86b 100644 (file)
@@ -913,7 +913,7 @@ void bnxt_re_unlock_cqs(struct bnxt_re_qp *qp,
        spin_unlock_irqrestore(&qp->scq->cq_lock, flags);
 }
 
-static int bnxt_re_destroy_gsi_sqp(struct bnxt_re_qp *qp)
+static void bnxt_re_destroy_gsi_sqp(struct bnxt_re_qp *qp)
 {
        struct bnxt_re_qp *gsi_sqp;
        struct bnxt_re_ah *gsi_sah;
@@ -933,10 +933,9 @@ static int bnxt_re_destroy_gsi_sqp(struct bnxt_re_qp *qp)
 
        ibdev_dbg(&rdev->ibdev, "Destroy the shadow QP\n");
        rc = bnxt_qplib_destroy_qp(&rdev->qplib_res, &gsi_sqp->qplib_qp);
-       if (rc) {
+       if (rc)
                ibdev_err(&rdev->ibdev, "Destroy Shadow QP failed");
-               goto fail;
-       }
+
        bnxt_qplib_free_qp_res(&rdev->qplib_res, &gsi_sqp->qplib_qp);
 
        /* remove from active qp list */
@@ -951,10 +950,6 @@ static int bnxt_re_destroy_gsi_sqp(struct bnxt_re_qp *qp)
        rdev->gsi_ctx.gsi_sqp = NULL;
        rdev->gsi_ctx.gsi_sah = NULL;
        rdev->gsi_ctx.sqp_tbl = NULL;
-
-       return 0;
-fail:
-       return rc;
 }
 
 static void bnxt_re_del_unique_gid(struct bnxt_re_dev *rdev)