Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp1355686ybn; Wed, 2 Oct 2019 14:58:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqwZ+aIRIRhS8tzeYqX2WpmozLuuefZmmu+hQBGdHI65itDfxoUME5xdluR828Vx/AFZKNe9 X-Received: by 2002:a17:906:d8a2:: with SMTP id qc2mr5087971ejb.10.1570053502269; Wed, 02 Oct 2019 14:58:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570053502; cv=none; d=google.com; s=arc-20160816; b=KjtcO5hxDTxgcRVVv4+2oEJ2tTz0n1XFfoG2vUvtH1bviwIN2+YflAxh9MQjUrO6xA ENis9Ti1vxXhsAJx/a5RJIFv3YjwDs+2BNCpDi6JTnFzyWi4XGhfRJD5Y70xi+Y+IWpd XjxObfjObYwhM0VSuprGBBY9+hwyVq46bnDNBxtJgJHYxYKqfYV7W5FeViAvU4HfIgFH uBiCh+29dyM+y2etyPBmCyUHmbWQ2dhqRuUoLIZVXtR7umCqJncl05YHOB9XsG7qHFXF ALyS+A2l0GpjwOTQ/+fbg/Wq2kqO8O0WDoBisU+OXzC+IPEGmQI+hQ24iIblM0rxIcaE KK3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=gnlFMlNypABzLw5irR8OlMn/0wqoIPMi5PCZlnfktBc=; b=UXnP41133lO5I44L7ammocfF+14S451+k/ERrg+LU1ag4RCrSdIIJOw134zp5GfM8h HWJaKdOYzMj36wW0jdI4BdVPUEqFJ6M+QlZG/pqdhecuVPxnQBz+O6HgdXpDxoy/BtAX 9+jHwnLJQzZ7Ce9JFrm4yQU8sLD3hDS7ENkzD8XqtWrzuEpivey2I/DhFe7YgtA1oNQl 7whNplTYFj8woBGmJ6lqh0frdMKTcvUtxE7cdYNYAJvdNUOJ/QWC/HTcmpbx3EqkYxvD 5UstVcxAtcH5/ZU7hTmpy+IhKf3qshILLguTSIuUz2ED4kqDvBO4qVjzsEmH8QuR+JGN cF+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="J/j7EnsM"; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id oz19si222168ejb.93.2019.10.02.14.57.58; Wed, 02 Oct 2019 14:58:22 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b="J/j7EnsM"; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728922AbfJBVfU (ORCPT + 99 others); Wed, 2 Oct 2019 17:35:20 -0400 Received: from mail-io1-f68.google.com ([209.85.166.68]:44370 "EHLO mail-io1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726491AbfJBVfT (ORCPT ); Wed, 2 Oct 2019 17:35:19 -0400 Received: by mail-io1-f68.google.com with SMTP id w12so690919iol.11; Wed, 02 Oct 2019 14:35:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=gnlFMlNypABzLw5irR8OlMn/0wqoIPMi5PCZlnfktBc=; b=J/j7EnsMpbJA8yJk7WiiiRf2aEycL7N0/yMWKKoWPvWx6QCGnBDEhzH0VAvC2v4CLQ v3V8kAyN7v16sscwmvWO9a+VXf0vyAGdXVGCVxhBdqjC56wlDbQd56WsaVMZ2EvQEPoS mdOyELSWmzbzPmgavFQ/sLMqUIyJNrrId5MQW/V44d41KtB9t8imArRpW9Owl140EBmf s0H0al/rVm9L7tJzM+rnU/Lm66AHNuRJ2vB2HFiBhPb5ssLPCB9jes2JUVQ0zpi1tBsc MFesIM8bAcUAXdJUVEKxyY918T/Z9RW4p4yY65wLFgHxe1mIqxEv1vXT0c7Eg67i6xTW ZxxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=gnlFMlNypABzLw5irR8OlMn/0wqoIPMi5PCZlnfktBc=; b=Nb2Ajg/b7P3nn68Gt3TgEDEf0Ef5a2Vy4d3gSmtrB1pcWlALGlF2mLCe0t4NXKksIZ hGE+XOaae45PFWGJC6/qn8OG9md5i02cWfr+37JZPt08r3zGSaE7AfRlA745XXcXc8CU orls7pWaxfWqFxMd4KQXnsyC8buQeB1QQOYXVfWrNbEhT3Ji7WQNwtaKYYG6yiujEO/W Me7IBk/1Sv3lXSH76i6rt+v0hr9Qlpy+r0b4Lmr2rRoC0WJF6G8Jqvw19P+IUaAqGSu9 ilVgRw3ldAankApAuUkriWfwhpXjPDNPI7iHBhA1ePtLTTbsbNiELVAsJgtLGSUULreX dXKg== X-Gm-Message-State: APjAAAXUrfzNY0F5q2b6akp/JqPvKjB/HgOxMq6LJFKD37nbF9dkuAOt Gc8oBL/wcMusvKlopp5AhwoaK1/O5vMS+sGlJn8= X-Received: by 2002:a92:b112:: with SMTP id t18mr6345688ilh.252.1570052117394; Wed, 02 Oct 2019 14:35:17 -0700 (PDT) MIME-Version: 1.0 References: <20190923050823.GL14368@unreal> <20190923155300.20407-1-navid.emamdoost@gmail.com> <20191001135430.GA27086@ziepe.ca> In-Reply-To: <20191001135430.GA27086@ziepe.ca> From: Navid Emamdoost Date: Wed, 2 Oct 2019 16:35:06 -0500 Message-ID: Subject: Re: [PATCH v2] RDMA: release allocated skb To: Jason Gunthorpe Cc: Leon Romanovsky , Navid Emamdoost , Stephen McCamant , Kangjie Lu , Potnuri Bharat Teja , Doug Ledford , linux-rdma@vger.kernel.org, LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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/ 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.