From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tetsuya Mukawa Subject: Re: [PATCH v8 03/12] eal: Fix memory leaks and needless increment of pci_map_addr Date: Wed, 08 Jul 2015 11:42:24 +0900 Message-ID: <559C8E10.3020207@igel.co.jp> 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> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: "dev@dpdk.org" To: David Marchand 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) In-Reply-To: List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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