From patchwork Sun Apr 23 01:26:51 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: 13221147 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 14037C77B76 for ; Sun, 23 Apr 2023 01:27:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230044AbjDWB1k (ORCPT ); Sat, 22 Apr 2023 21:27:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230082AbjDWB1h (ORCPT ); Sat, 22 Apr 2023 21:27:37 -0400 Received: from mail1.bemta34.messagelabs.com (mail1.bemta34.messagelabs.com [195.245.231.2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B46030D0; Sat, 22 Apr 2023 18:27:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fujitsu.com; s=170520fj; t=1682213253; i=@fujitsu.com; bh=W4sJFNaU5Kv134M+xnc5Z7XEkhGC4xXYWGqOZ13zAns=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=FJVHNU70chKRKd8zorz8HeF4+bCBlUzsWZwZfdNdjBKY/QKCcZyDIsEZtOtRpurfm O0OqecTCcBKaq+ME09Oo/l2quZVENvhs4dsvZ0az8XaE1K18mIBeJIycERXs+uj7n3 8+9Gj+1PD2ggve3v0xEuM8NPU/3U8UovsOVvHaOtcMBpBDjlCWWaP+PeyOozLLHVxT QYiBviorB6g65LcWCxUE4yy60FgB4hSveTtjtugG6PPTM2J/Q16qXWi/L144DJOD7l MMPr2lZXxyH0vZ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yGV9Dmsp9Lp7oNwrBUZx8KnuP PpvwcvI1jeToYwG9rpX7IuNTKj79OJ5RLxaX921S6JsrSnKzFJtjWXf4TxaeyPpH55cSS3FGo qEWc1FxIgDmC3JdiQMAAA== X-Env-Sender: lizhijian@fujitsu.com X-Msg-Ref: server-18.tower-565.messagelabs.com!1682213251!159822!1 X-Originating-IP: [62.60.8.179] X-SYMC-ESS-Client-Auth: outbound-route-from=pass X-StarScan-Received: X-StarScan-Version: 9.105.2; banners=-,-,- X-VirusChecked: Checked Received: (qmail 861 invoked from network); 23 Apr 2023 01:27:31 -0000 Received: from unknown (HELO n03ukasimr04.n03.fujitsu.local) (62.60.8.179) by server-18.tower-565.messagelabs.com with ECDHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 23 Apr 2023 01:27:31 -0000 Received: from n03ukasimr04.n03.fujitsu.local (localhost [127.0.0.1]) by n03ukasimr04.n03.fujitsu.local (Postfix) with ESMTP id 5E8C4170; Sun, 23 Apr 2023 02:27:31 +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 n03ukasimr04.n03.fujitsu.local (Postfix) with ESMTPS id 5249F150; Sun, 23 Apr 2023 02:27:31 +0100 (BST) Received: from d3e152dc4f88.localdomain (10.167.226.45) by R01UKEXCASM223.r01.fujitsu.local (10.182.185.121) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Sun, 23 Apr 2023 02:27:28 +0100 From: Li Zhijian To: , , , , CC: , , Li Zhijian Subject: [PATCH for-next v2 2/3] RDMA/rtrs: Fix the last iu->buf leak in err path Date: Sun, 23 Apr 2023 01:26:51 +0000 Message-ID: <1682213212-2-3-git-send-email-lizhijian@fujitsu.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1682213212-2-1-git-send-email-lizhijian@fujitsu.com> References: <1682213212-2-1-git-send-email-lizhijian@fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.226.45] 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. Signed-off-by: Li Zhijian Acked-by: Jack Wang --- 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;