Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp4452821rdh; Wed, 29 Nov 2023 01:48:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IFvjoXXaeRnWuXU2RqCjJml+pvhpCSMCxxnLxwRBqejVTkXh+XnqSMhDwMs2cHzacK5nBRO X-Received: by 2002:a05:6808:d54:b0:3b8:63aa:827b with SMTP id w20-20020a0568080d5400b003b863aa827bmr14265812oik.6.1701251311280; Wed, 29 Nov 2023 01:48:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701251311; cv=none; d=google.com; s=arc-20160816; b=h40FbmFkGa3tlmJAXhKTZ0v1V2oFgQJgkqh5zW6xqoOfxBamZY2PZ/JKhgBlAJgix1 scCkKwUNsf9ZSTfov/1hh2nqxP6tzl5mQdbZEQ2VIV74z5MPRkrg5dgMiw8N+G3flmhS 80zbUSfGCV9DbdYo/wWIYF9l62M3/fIxvhjAj43+ZbM4TaEkfhXuXCPYE/RRdrecZO0W mjjovpX/JUSP2pmBmtyufP5cJ3ZdGzdzLVk96ooQDcpNdOualS7WDXSJAFk3osGqyFwY sOayLNSjX57Q6VJtS3z1YdP7ObpGPhLJR5fOqwzpVnV/PiMM7qhYN3Gok2+W5qD31rr8 nkug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=ldwZpovtywSD1PD1lfHfav/Vz6ZSCZ5gOTnq6KoNzWc=; fh=KWvyQxL3Ff+3WPSMjlYu+P4255AmcMULAsFol6M1vNI=; b=CGZeaYeC7V8obgMeX89wXPL+EsOVp+yotDSnW7zp5pji+o0htcB6bgCl5nYrNp0I65 Y/Dc4Mubi/j+76MlQKfjQHtrURSxR37royMoNZi86nQ69CimuYdG58mvqpPAcq64tUg/ W+w0+gisHR7zdaHUOsWCtM2rJ0vAEV3pHW+JYwvQ4n//2s8RYpwTjN5ibQDGXEJm9+dp ZbPS/42xEWM0GJONIULQx6LdrZ3uDAAdwjwr+7c3O0od5/g84s8kiCE3rcJBFzUDEVKZ ZNztIihsrWLzpiQ267HSfd3MfA12fbvwcNapbBc276wyXSl1D52+YGTqOEgqACRY/uWA h5sw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=hisilicon.com Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id f22-20020a056a0022d600b006bca1246564si14080638pfj.271.2023.11.29.01.48.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 01:48:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=hisilicon.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 2095C8031E20; Wed, 29 Nov 2023 01:48:30 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230298AbjK2JsT (ORCPT + 99 others); Wed, 29 Nov 2023 04:48:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229753AbjK2JsF (ORCPT ); Wed, 29 Nov 2023 04:48:05 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F08ABD6C; Wed, 29 Nov 2023 01:48:10 -0800 (PST) Received: from kwepemi500006.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4SgDy52WpmzWh99; Wed, 29 Nov 2023 17:47:25 +0800 (CST) Received: from localhost.localdomain (10.67.165.2) by kwepemi500006.china.huawei.com (7.221.188.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Wed, 29 Nov 2023 17:48:08 +0800 From: Junxian Huang To: , CC: , , , Subject: [PATCH for-rc 5/6] RDMA/hns: Fix memory leak in free_mr_init() Date: Wed, 29 Nov 2023 17:44:33 +0800 Message-ID: <20231129094434.134528-6-huangjunxian6@hisilicon.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20231129094434.134528-1-huangjunxian6@hisilicon.com> References: <20231129094434.134528-1-huangjunxian6@hisilicon.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.67.165.2] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To kwepemi500006.china.huawei.com (7.221.188.68) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 29 Nov 2023 01:48:30 -0800 (PST) From: Chengchang Tang When a reserved QP fails to be created, the memory of the remaining created reserved QPs is leaked. Fixes: 70f92521584f ("RDMA/hns: Use the reserved loopback QPs to free MR before destroying MPT") Signed-off-by: Chengchang Tang Signed-off-by: Junxian Huang --- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c index 8126922b4e21..538f3e8949fc 100644 --- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c +++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c @@ -2705,6 +2705,10 @@ static int free_mr_alloc_res(struct hns_roce_dev *hr_dev) return 0; create_failed_qp: + for (i--; i >= 0; i--) { + hns_roce_v2_destroy_qp(&free_mr->rsv_qp[i]->ibqp, NULL); + kfree(free_mr->rsv_qp[i]); + } hns_roce_destroy_cq(cq, NULL); kfree(cq); -- 2.30.0