Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp4076005rwr; Sat, 22 Apr 2023 20:09:01 -0700 (PDT) X-Google-Smtp-Source: AKy350YrcCZsn5JWNZmaId3PNKjDuNJWyGf3WUJ6G/fkQX1pNsy5WD/d52LFFlKNKzTlYBCMu0UN X-Received: by 2002:a17:902:d4c2:b0:1a9:6467:aa8d with SMTP id o2-20020a170902d4c200b001a96467aa8dmr3008136plg.1.1682219341484; Sat, 22 Apr 2023 20:09:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682219341; cv=none; d=google.com; s=arc-20160816; b=TaLJslGuFSP4ugfvEpiHFQ8VEOEje89hwytYxUWm7mzHxOMY3ZW7SK3DeypxCzMEoD ueUlAjTBwUdIv5MAVWPqYqeXFgwH/yaJW20HcbZ5J+/X9ylgyl1w9dxDgOmOP6iew84y RbVjR61KASDqRM60wFjNfBD4lnmSr1YyHpvZIh1aAe3KTx/8V5trPQ+SzcnVPGAqi8Ns LePaK+mr22g0dzTdbV6NlXvxbvNhkvpuY3UGotmHpFTUnyQuXQLA6LBk3WKSAvPe/iyO rsXqIzHS1CbOE4QAdsxwexTP9IORuQot/ya18oYCTBb/uKu5gRl0XStJBIiLd8ExAC8/ 28OQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :content-language:references:cc:to:subject:from:mime-version:date :dkim-signature:message-id; bh=0dgL3xDEkr6o6FRjE7kxu44l06Ma5AgulZJtHgzYbLM=; b=Wrolxe0iVv0O2Ov4UWq+8w/2QVu8HG6MlqXpn9GCFbErwG6d/RfQ2zNIS/4+QyJlBt rGqaJauo6WCJRBC7PkIsnGJ9oWBzRnn3pKpOf4enpRSFr85SV/4OTdz2SmFunBP9N9Hf XlJZaFBOx2DDdOKksjHAr856lXvE69gQ2qrZtjkkBCZDV7IliHDeWbBbsptTF04RyIbg yPaNfm/mNHFo5/3Zrbd0q4omaYOZAnyMh0RmEvfNAn6bIVgKupNFVtXEZdzvkcutCnkb OyybN+JSQ7Yk9VP+QzOkCMh4VpUAoa+0JaNqNbgE7EvbWkDddYJ/K+Ls1/UlXGGtTa9e ni9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=Q7m1T9Ys; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mg21-20020a17090b371500b002467eaf62d8si7838669pjb.157.2023.04.22.20.08.48; Sat, 22 Apr 2023 20:09:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=Q7m1T9Ys; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230126AbjDWC4m (ORCPT + 99 others); Sat, 22 Apr 2023 22:56:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229556AbjDWC4l (ORCPT ); Sat, 22 Apr 2023 22:56:41 -0400 Received: from out-23.mta1.migadu.com (out-23.mta1.migadu.com [IPv6:2001:41d0:203:375::17]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33A9B2136 for ; Sat, 22 Apr 2023 19:56:40 -0700 (PDT) Message-ID: <58a984d3-a89d-89d4-2491-a559bc8b1076@linux.dev> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1682218598; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0dgL3xDEkr6o6FRjE7kxu44l06Ma5AgulZJtHgzYbLM=; b=Q7m1T9YsWl4Y5ORRjicXCwxB8qgnMV8rW0ao/MMqnGtjS/1xpC04DP0cpOg/8PZWz6HR9e aqaE9qWi/pMPNbDmkT56zCKn0NGohsQj1+mLYtklDWTJT0dhfomnfGm2xzsAwpNIpr2g3U od8Oirq5s7ybLp19iol11dEW46qadf0= Date: Sun, 23 Apr 2023 10:56:30 +0800 MIME-Version: 1.0 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Guoqing Jiang Subject: Re: [PATCH for-next v2 2/3] RDMA/rtrs: Fix the last iu->buf leak in err path To: Li Zhijian , haris.iqbal@ionos.com, jinpu.wang@ionos.com, jgg@ziepe.ca, leon@kernel.org, linux-rdma@vger.kernel.org Cc: linux-kernel@vger.kernel.org References: <1682213212-2-1-git-send-email-lizhijian@fujitsu.com> <1682213212-2-3-git-send-email-lizhijian@fujitsu.com> Content-Language: en-US In-Reply-To: <1682213212-2-3-git-send-email-lizhijian@fujitsu.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 On 4/23/23 09:26, Li Zhijian wrote: > 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 > --- > 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; Good catch, Acked-by: Guoqing Jiang Thanks, Guoqing