From patchwork Tue Apr 25 01:02:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhijian Li (Fujitsu)" X-Patchwork-Id: 13222755 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EEBA8C77B7F for ; Tue, 25 Apr 2023 01:04:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232634AbjDYBEq (ORCPT ); Mon, 24 Apr 2023 21:04:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232473AbjDYBEm (ORCPT ); Mon, 24 Apr 2023 21:04:42 -0400 Received: from mail1.bemta34.messagelabs.com (mail1.bemta34.messagelabs.com [195.245.231.2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 590A4B468; Mon, 24 Apr 2023 18:04:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fujitsu.com; s=170520fj; t=1682384665; i=@fujitsu.com; bh=1lOrz3WkF8WW2Sm93QlBxTpItpbsuBYyhX73hc+vyXw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=xdPv68VjjDrapfyV6edaawjiHuptKdVLwrVQw49Zql7B6fLNT9k3X6RWOufAupU+K 3ikOXCj0KXMB1NSdg6ynfcLzNRDkx6XxeeNNS0hENd03/Bczttj4tfUMl4QRhTIwrr ZfG5QyCQbdLU3xGDC0aezZTvU8pFi7MvIprKQNw+T9zoVl4XEOCjZdAAGme7v0YIBT H9GCJc9o41WSVAPkntlR/U0se45uU+qdqErnRt7Cis72K4XfPNDlRUV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1H/ytL5QvImN6QO2rKdni4Svld6 VZvy4fyr2pnZdzJiJrzwkz7/990WtSP+O8TO3Dq7MOFi2DZ5pQ/CTxY4Ox4K005ez2W4xiO+Q YmlOCPRUIu5qDgRAMBUMrSKAwAA X-Env-Sender: lizhijian@fujitsu.com X-Msg-Ref: server-13.tower-565.messagelabs.com!1682384664!308683!1 X-Originating-IP: [62.60.8.98] X-SYMC-ESS-Client-Auth: outbound-route-from=pass X-StarScan-Received: X-StarScan-Version: 9.105.2; banners=-,-,- X-VirusChecked: Checked Received: (qmail 11972 invoked from network); 25 Apr 2023 01:04:24 -0000 Received: from unknown (HELO n03ukasimr03.n03.fujitsu.local) (62.60.8.98) by server-13.tower-565.messagelabs.com with ECDHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 25 Apr 2023 01:04:24 -0000 Received: from n03ukasimr03.n03.fujitsu.local (localhost [127.0.0.1]) by n03ukasimr03.n03.fujitsu.local (Postfix) with ESMTP id 195BE1BC; Tue, 25 Apr 2023 02:04:24 +0100 (BST) Received: from R01UKEXCASM223.r01.fujitsu.local (R01UKEXCASM223 [10.182.185.121]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by n03ukasimr03.n03.fujitsu.local (Postfix) with ESMTPS id 0D05F1C0; Tue, 25 Apr 2023 02:04:24 +0100 (BST) Received: from 0819309620d6.localdomain (10.167.234.230) by R01UKEXCASM223.r01.fujitsu.local (10.182.185.121) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Tue, 25 Apr 2023 02:04:20 +0100 From: Li Zhijian To: , , CC: , , , , Li Zhijian Subject: [PATCH for-next v3 2/3] RDMA/rtrs: Fix the last iu->buf leak in err path Date: Tue, 25 Apr 2023 01:02:42 +0000 Message-ID: <1682384563-2-3-git-send-email-lizhijian@fujitsu.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1682384563-2-1-git-send-email-lizhijian@fujitsu.com> References: <1682384563-2-1-git-send-email-lizhijian@fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.234.230] X-ClientProxiedBy: G08CNEXCHPEKD07.g08.fujitsu.local (10.167.33.80) To R01UKEXCASM223.r01.fujitsu.local (10.182.185.121) X-Virus-Scanned: ClamAV using ClamSMTP Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org The last iu->buf will leak if ib_dma_mapping_error() fails. Fixes: c0894b3ea69d ("RDMA/rtrs: core: lib functions shared between client and server modules") Signed-off-by: Li Zhijian Acked-by: Guoqing Jiang Acked-by: Jack Wang --- V3: add fixes and acked tags V2: new patch to address memory leaking --- drivers/infiniband/ulp/rtrs/rtrs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs.c b/drivers/infiniband/ulp/rtrs/rtrs.c index 4bf9d868cc52..3696f367ff51 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs.c +++ b/drivers/infiniband/ulp/rtrs/rtrs.c @@ -37,8 +37,10 @@ struct rtrs_iu *rtrs_iu_alloc(u32 iu_num, size_t size, gfp_t gfp_mask, goto err; iu->dma_addr = ib_dma_map_single(dma_dev, iu->buf, size, dir); - if (ib_dma_mapping_error(dma_dev, iu->dma_addr)) + if (ib_dma_mapping_error(dma_dev, iu->dma_addr)) { + kfree(iu->buf); goto err; + } iu->cqe.done = done; iu->size = size;