Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp174382ybn; Thu, 3 Oct 2019 03:27:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqyIUSpDUHheKAVPAaTzvYHLLzhakVsWKUrL+w8MO4hKVy9OyULha3z9f9RtGkBFZS6BNHwQ X-Received: by 2002:a50:fa9a:: with SMTP id w26mr8652003edr.227.1570098426076; Thu, 03 Oct 2019 03:27:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570098426; cv=none; d=google.com; s=arc-20160816; b=RrqCIbtFguQLYw8e45XtdUteB0f/k4/C1NhocDrxnvqjrBexTl++oOKc0Bgn9CtOFN ocOWkQaTEILqJQM74msirzBP5ORdYkDx0MMibkYAmKB8au7brjsMvKIRDjtdDYat8NBO FeZFf4L91fEDxU8Dbwae4y1+HGJgVtqzoZ2HvSddoRkpwBsV66ek8kn5RJEtZVZq7kkF oJmrv44VTtLpLfR3rVHkW6tV+j+epJpB1IXnftId9iWiWLQy5jeBx4ScRHFqWj90HUUr XiqWLr19TNjp+plwREurzni+nJfGpW4SeQdQ+IeB37Vb6LGBFnEIWhhInxdmE7Hd5Tal jl1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=EOqaudcbOBdpVcoDr2wqXuOh6i5+OKIWgV+790TrRbI=; b=Q39DPOBv+i+SbW+cECx21S6wjQjxlFomyqigJr6QWMx/jmdUYxwIM6P1ltk42QU0oh SHwbT6EL8LXY8ZyiyMajmUilhPgaoIAiEPrWf4ZVISddCX5abUifb9eEresghc8bQ8TZ X2uGSpfqloXuuKCtXTuVD6n+TkGO6WJZCKetruaj6QJP+QNFMYlHDyNGfA3L7NKkyA8B TU3KIjGagbNtb9lOJDoOmI4tykuk8+4BnMpDtdw9ace2H0zdl2jAtrEyQ0mI3e4KIMDG 7qSAQJBobdOCZx3PYFnG0YaWlLiamqxmdyfal2JKTCBwes+hIZU8xjAJYme4nF4j4I+G kz+w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p18si1051904ejn.370.2019.10.03.03.26.41; Thu, 03 Oct 2019 03:27:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728665AbfJCKZh (ORCPT + 99 others); Thu, 3 Oct 2019 06:25:37 -0400 Received: from stargate.chelsio.com ([12.32.117.8]:18102 "EHLO stargate.chelsio.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727452AbfJCKZh (ORCPT ); Thu, 3 Oct 2019 06:25:37 -0400 Received: from localhost (mehrangarh.blr.asicdesigners.com [10.193.185.169]) by stargate.chelsio.com (8.13.8/8.13.8) with ESMTP id x93APHcP026009; Thu, 3 Oct 2019 03:25:18 -0700 Date: Thu, 3 Oct 2019 15:55:11 +0530 From: Potnuri Bharat Teja To: Navid Emamdoost Cc: Jason Gunthorpe , Leon Romanovsky , Navid Emamdoost , Stephen McCamant , Kangjie Lu , Doug Ledford , "linux-rdma@vger.kernel.org" , LKML Subject: Re: [PATCH v2] RDMA: release allocated skb Message-ID: <20191003102510.GA10875@chelsio.com> References: <20190923050823.GL14368@unreal> <20190923155300.20407-1-navid.emamdoost@gmail.com> <20191001135430.GA27086@ziepe.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thursday, October 10/03/19, 2019 at 03:05:06 +0530, Navid Emamdoost wrote: > Hi Jason, > > Thanks for the feedback. Yes, you are right if the skb release is > moved under err4 label it will cause a double free as > c4iw_ref_send_wait will release skb in case of error. > So, in order to avoid leaking skb in case of c4iw_bar2_addrs failure, > the kfree(skb) could be placed under the error check like the way > patch v1 did. Do you see any mistake in version 1? > https://lore.kernel.org/patchwork/patch/1128510/ Hi Navid, Both the revisions of the patch are invalid. skb is freed in both the cases of failure and success through c4iw_ofld_send(). case success: in ctrl_xmit() case failure: in c4iw_ofld_send() Thanks, Bharat. > > > Thanks, > Navid > > On Tue, Oct 1, 2019 at 8:54 AM Jason Gunthorpe wrote: > > > > On Mon, Sep 23, 2019 at 10:52:59AM -0500, Navid Emamdoost wrote: > > > In create_cq, the allocated skb buffer needs to be released on error > > > path. > > > Moved the kfree_skb(skb) under err4 label. > > > > This didn't move anything > > > > > Signed-off-by: Navid Emamdoost > > > drivers/infiniband/hw/cxgb4/cq.c | 1 + > > > 1 file changed, 1 insertion(+) > > > > > > diff --git a/drivers/infiniband/hw/cxgb4/cq.c b/drivers/infiniband/hw/cxgb4/cq.c > > > index b1bb61c65f4f..1886c1af10bc 100644 > > > +++ b/drivers/infiniband/hw/cxgb4/cq.c > > > @@ -173,6 +173,7 @@ static int create_cq(struct c4iw_rdev *rdev, struct t4_cq *cq, > > > err4: > > > dma_free_coherent(&rdev->lldi.pdev->dev, cq->memsize, cq->queue, > > > dma_unmap_addr(cq, mapping)); > > > + kfree_skb(skb); > > > err3: > > > kfree(cq->sw_queue); > > > err2: > > > > This looks wrong to me: > > > > int c4iw_ofld_send(struct c4iw_rdev *rdev, struct sk_buff *skb) > > { > > int error = 0; > > > > if (c4iw_fatal_error(rdev)) { > > kfree_skb(skb); > > pr_err("%s - device in error state - dropping\n", __func__); > > return -EIO; > > } > > error = cxgb4_ofld_send(rdev->lldi.ports[0], skb); > > if (error < 0) > > kfree_skb(skb); > > return error < 0 ? error : 0; > > } > > > > Jason > > > > -- > Navid.