From nobody Thu Oct 2 06:21:37 2025 Received: from mailgw.kylinos.cn (mailgw.kylinos.cn [124.126.103.232]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F1D3A239E9A; Mon, 22 Sep 2025 02:23:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=124.126.103.232 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758507802; cv=none; b=pMt0fk5sMEhn/KgaNIrp4Ye1TqNBtpFcrgJ2YWiux1h6eJnn/BVIeRjXHwJTFf6f9MvcupBUnmhvicbRiLxN0ASgOIiy5fdgGm0GepY+vydxOCXz+spdTvFE6yOIqlrRfLpcspSa5UaqIQymJjO0v2Lkc9wHRc7pOgKNK8tkl84= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758507802; c=relaxed/simple; bh=ivSPbVdKipX7Q7V4zcUvxvFhobL0E3ii3lnlqHGQKoU=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=VZro8p0xrNgy82VUwuhP5FcEPIfe6HZuyuhuXGAxMq/N65zHuFM75G2J4qH0hJSJgAK7SY8F8oVT/M/7ahiib+0yAhLcVeZ/f96xCQa5iFry8ZAhFpFIq2cafsLtwNxa4eG/ywt470nfAtjtC2vQIUnktseEVN8EmkKzg0hVMWQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn; spf=pass smtp.mailfrom=kylinos.cn; arc=none smtp.client-ip=124.126.103.232 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kylinos.cn X-UUID: 12efbf36975b11f0b29709d653e92f7d-20250922 X-CTIC-Tags: HR_CC_COUNT, HR_CC_DOMAIN_COUNT, HR_CC_NO_NAME, HR_CTE_8B, HR_CTT_MISS HR_DATE_H, HR_DATE_WKD, HR_DATE_ZONE, HR_FROM_NAME, HR_SJ_LANG HR_SJ_LEN, HR_SJ_LETTER, HR_SJ_NOR_SYM, HR_SJ_PHRASE, HR_SJ_PHRASE_LEN HR_SJ_WS, HR_TO_COUNT, HR_TO_DOMAIN_COUNT, HR_TO_NO_NAME, IP_TRUSTED SRC_TRUSTED, DN_TRUSTED, SA_UNTRUSTED, SA_UNFAMILIAR, SN_EXISTED SPF_NOPASS, DKIM_NOPASS, DMARC_NOPASS, CIE_BAD, CIE_GOOD CIE_GOOD_SPF, GTI_FG_BS, GTI_RG_INFO, GTI_C_BU, AMN_T1 AMN_GOOD, AMN_C_TI, AMN_C_BU, ABX_MISS_RDNS X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.45,REQID:d03f2e50-b735-40f1-b127-8bf6ac12c0b8,IP:10, URL:0,TC:0,Content:0,EDM:25,RT:0,SF:-5,FILE:0,BULK:0,RULE:Release_Ham,ACTI ON:release,TS:30 X-CID-INFO: VERSION:1.1.45,REQID:d03f2e50-b735-40f1-b127-8bf6ac12c0b8,IP:10,UR L:0,TC:0,Content:0,EDM:25,RT:0,SF:-5,FILE:0,BULK:0,RULE:Release_Ham,ACTION :release,TS:30 X-CID-META: VersionHash:6493067,CLOUDID:a2132ba13756cbc00a55a00bd95ca598,BulkI D:2509191136030BJLPMJW,BulkQuantity:4,Recheck:0,SF:19|24|44|66|72|78|102|8 50,TC:nil,Content:0|50,EDM:5,IP:-2,URL:0,File:nil,RT:nil,Bulk:40,QS:nil,BE C:nil,COL:0,OSI:0,OSA:0,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR,TF_CID_SPAM_FSD,TF_CID_SPAM_FSI X-UUID: 12efbf36975b11f0b29709d653e92f7d-20250922 X-User: daiyanlong@kylinos.cn Received: from localhost.localdomain [(223.70.159.239)] by mailgw.kylinos.cn (envelope-from ) (Generic MTA with TLSv1.3 TLS_AES_256_GCM_SHA384 256/256) with ESMTP id 1905651554; Mon, 22 Sep 2025 10:23:06 +0800 From: YanLong Dai To: kalesh-anakkur.purayil@broadcom.com Cc: jgg@ziepe.ca, leon@kernel.org, linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org, selvin.xavier@broadcom.com, daiyanlong@kylinos.cn, dyl_wlc@163.com Subject: [PATCH] RDMA/bnxt_re: Fix a potential memory leak in destroy_gsi_sqp Date: Mon, 22 Sep 2025 10:22:55 +0800 Message-ID: <20250922022255.4818-1-daiyanlong@kylinos.cn> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: daiyanlong 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: daiyanlong --- drivers/infiniband/hw/bnxt_re/ib_verbs.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/infiniband/hw/bnxt_re/ib_verbs.c b/drivers/infiniband/= hw/bnxt_re/ib_verbs.c index 260dc67b8b87..15d3f5d5c0ee 100644 --- a/drivers/infiniband/hw/bnxt_re/ib_verbs.c +++ b/drivers/infiniband/hw/bnxt_re/ib_verbs.c @@ -931,10 +931,9 @@ static int bnxt_re_destroy_gsi_sqp(struct bnxt_re_qp *= qp) =20 ibdev_dbg(&rdev->ibdev, "Destroy the shadow QP\n"); rc =3D 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); =20 /* remove from active qp list */ @@ -951,8 +950,6 @@ static int bnxt_re_destroy_gsi_sqp(struct bnxt_re_qp *q= p) rdev->gsi_ctx.sqp_tbl =3D NULL; =20 return 0; -fail: - return rc; } =20 /* Queue Pairs */ --=20 2.43.0