From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pd0-f172.google.com (mail-pd0-f172.google.com [209.85.192.172]) by dpdk.org (Postfix) with ESMTP id DB5F55A64 for ; Wed, 8 Jul 2015 04:42:28 +0200 (CEST) Received: by pdbdz6 with SMTP id dz6so41893336pdb.0 for ; Tue, 07 Jul 2015 19:42:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :cc:subject:references:in-reply-to:content-type :content-transfer-encoding; bh=RwxwraipwXsmHI5+mfdWiD//5gu6Nd7MVKaEndtWovg=; b=ejg2n6frikpAD2y3e9jJ1Fe0qBs86a0R4qBRqQDgLNoygRkAyU4oGhvTL+1zWPXjMG OQaVTjeXlPN/S9psa4/wKtnt1DcdbiYik9/vHaV+9wHDsse+v+V0WL+ML7I5+ENkrJ04 gx374m3NdNjxkbYJeK37VcFSAt3IJP+no/gHFv9tBGo2K1N05cgzvU20qF8UA9OdbDhw sQJXvdAImFcpMXa51Dyi+0oX6mrlFWWBCmbUD5Gdm1fK84IsFBLYrr65PB8gfb1NtHEm XdPVOlpN+V+1kxBrU1aYlmSfK7Gl9c9ZzkLQq8SzFYkrvvSTRaSr5WqRUHJEuMU4t3w8 Hx0A== X-Gm-Message-State: ALoCoQmo+cyZPn0jHUBcGE5W5I/CaQYsiSwJCsKbYDRK2HimS21EA4dd+f4XZMyBFbXdNy8EO5tw X-Received: by 10.68.225.42 with SMTP id rh10mr15339606pbc.158.1436323348315; Tue, 07 Jul 2015 19:42:28 -0700 (PDT) Received: from [10.16.129.101] (napt.igel.co.jp. [219.106.231.132]) by smtp.googlemail.com with ESMTPSA id on3sm532232pbc.48.2015.07.07.19.42.26 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Jul 2015 19:42:27 -0700 (PDT) Message-ID: <559C8E10.3020207@igel.co.jp> Date: Wed, 08 Jul 2015 11:42:24 +0900 From: Tetsuya Mukawa User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: David Marchand References: <1435652668-3380-12-git-send-email-mukawa@igel.co.jp> <1436163861-3025-1-git-send-email-mukawa@igel.co.jp> <1436163861-3025-4-git-send-email-mukawa@igel.co.jp> In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: "dev@dpdk.org" Subject: Re: [dpdk-dev] [PATCH v8 03/12] eal: Fix memory leaks and needless increment of pci_map_addr X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Jul 2015 02:42:29 -0000 On 2015/07/07 17:04, David Marchand wrote: > Hello Tetsuya, > > Little comment below for this patch. > > On Mon, Jul 6, 2015 at 8:24 AM, Tetsuya Mukawa > wrote: > > > diff --git a/lib/librte_eal/bsdapp/eal/eal_pci.c > b/lib/librte_eal/bsdapp/eal/eal_pci.c > index a63d450..63758c7 100644 > --- a/lib/librte_eal/bsdapp/eal/eal_pci.c > +++ b/lib/librte_eal/bsdapp/eal/eal_pci.c > @@ -202,7 +202,7 @@ pci_uio_map_resource(struct rte_pci_device *dev) > uint64_t offset; > uint64_t pagesz; > struct rte_pci_addr *loc = &dev->addr; > - struct uio_resource *uio_res; > + struct uio_resource *uio_res = NULL; > struct uio_res_list *uio_res_list = > RTE_TAILQ_CAST(rte_uio_tailq.head, > uio_res_list); > struct uio_map *maps; > [snip] > @@ -275,6 +274,16 @@ pci_uio_map_resource(struct rte_pci_device *dev) > TAILQ_INSERT_TAIL(uio_res_list, uio_res, next); > > return 0; > + > +error: > + if (uio_res) > + rte_free(uio_res); > > > As long as uio_res is initialized to NULL, no need to check. > rte_free() behaves the same as free(). > Oh, I didn't notice it. Thanks. > > diff --git a/lib/librte_eal/linuxapp/eal/eal_pci_uio.c > b/lib/librte_eal/linuxapp/eal/eal_pci_uio.c > index 37dc936..4e50533 100644 > --- a/lib/librte_eal/linuxapp/eal/eal_pci_uio.c > +++ b/lib/librte_eal/linuxapp/eal/eal_pci_uio.c > [snip] > @@ -400,6 +397,25 @@ pci_uio_map_resource(struct rte_pci_device *dev) > TAILQ_INSERT_TAIL(uio_res_list, uio_res, next); > > return 0; > + > +error: > + for (i = 0; i < map_idx; i++) { > + pci_unmap_resource(uio_res->maps[i].addr, > + (size_t)uio_res->maps[i].size); > + rte_free(maps[i].path); > + } > + if (uio_res) > + rte_free(uio_res); > > > Idem. > > > With this, > Acked-by: David Marchand > > I will fix codes like above. Tetsuya > -- > David Marchand