From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oi0-f43.google.com (mail-oi0-f43.google.com [209.85.218.43]) by dpdk.org (Postfix) with ESMTP id 10B235A72 for ; Wed, 18 Mar 2015 16:39:22 +0100 (CET) Received: by oiag65 with SMTP id g65so39530490oia.2 for ; Wed, 18 Mar 2015 08:39:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=Jp5lZNrbLDyVmc/SXnCp/RHuCHsqIF4svHhPP42y3Wo=; b=RBgKmL7F5cmfHQMsZ49vddAAIhp2jrSWkUNXJIJsytnH/IjxDilLMrKSzuavj6DdoP XXQTu/T1eintpBlLAfhnu1joVUKC+GgJ3MtfrSAwoOTJ/ZrivwQ0441Dmb+yQxAFeJYz 9DA1O2smhxjyua36Y6RUedvbEW1/9qBUPVYDULETCExcJL9KwMTFCzBoB+jmlOJWkpla naycOyidT3d8IZ4f0j3nlfTCpO2Zci2TTHN92H3Weib7a7SnrDeLXf+5Rtw4uCY8xNXY DJ8QezMlzymLP9szejKF6pzjVV9ifGZ4sIIE7ZEyteAb50yiUdcK8cX7Ub87qST+AIG1 l5/g== X-Gm-Message-State: ALoCoQmbJjWwJS5dcmVQ90qjphb/0y1UGdo/C0viIZIaDaIU8XcntqYT4DhxXLHoZaxD5VHYtpEo MIME-Version: 1.0 X-Received: by 10.182.251.138 with SMTP id zk10mr58454495obc.72.1426693161375; Wed, 18 Mar 2015 08:39:21 -0700 (PDT) Received: by 10.76.34.35 with HTTP; Wed, 18 Mar 2015 08:39:21 -0700 (PDT) In-Reply-To: <1426584645-28828-4-git-send-email-mukawa@igel.co.jp> References: <1426155474-1596-4-git-send-email-mukawa@igel.co.jp> <1426584645-28828-1-git-send-email-mukawa@igel.co.jp> <1426584645-28828-4-git-send-email-mukawa@igel.co.jp> Date: Wed, 18 Mar 2015 16:39:21 +0100 Message-ID: From: David Marchand To: Tetsuya Mukawa Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Cc: "dev@dpdk.org" Subject: Re: [dpdk-dev] [PATCH 3/6] eal: Fix memory leaks and needless incrementation of pci uio implementation 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, 18 Mar 2015 15:39:22 -0000 On Tue, Mar 17, 2015 at 10:30 AM, Tetsuya Mukawa wrote: > When pci_map_resource() is failed but path is allocated correctly, > path won't be freed. Also, when open() is failed, uio_res won't be freed. > This patch fixes these memory leaks. > When pci_map_resource() is failed, mapaddr will be MAP_FAILED. > In this case, pci_map_addr should not be incremented. > > Also, the patch fixes belows. > - To shrink code, move close(). > - Remove fail variable. > > Signed-off-by: Tetsuya Mukawa > --- > lib/librte_eal/linuxapp/eal/eal_pci_uio.c | 28 > ++++++++++++++-------------- > 1 file changed, 14 insertions(+), 14 deletions(-) > > diff --git a/lib/librte_eal/linuxapp/eal/eal_pci_uio.c > b/lib/librte_eal/linuxapp/eal/eal_pci_uio.c > index b971ec9..5044884 100644 > --- a/lib/librte_eal/linuxapp/eal/eal_pci_uio.c > +++ b/lib/librte_eal/linuxapp/eal/eal_pci_uio.c > @@ -333,7 +333,6 @@ pci_uio_map_resource(struct rte_pci_device *dev) > maps = uio_res->maps; > for (i = 0, map_idx = 0; i != PCI_MAX_RESOURCE; i++) { > int fd; > - int fail = 0; > > /* skip empty BAR */ > phaddr = dev->mem_resource[i].phys_addr; > @@ -347,6 +346,11 @@ pci_uio_map_resource(struct rte_pci_device *dev) > loc->domain, loc->bus, loc->devid, > loc->function, > i); > > + /* allocate memory to keep path */ > + maps[map_idx].path = rte_malloc(NULL, strlen(devname) + 1, > 0); > + if (maps[map_idx].path == NULL) > + goto fail0; > + > [snip] Neither fail0 nor fail1 labels seem to free previous allocations. Did I miss something ? [snip] + > +fail1: > + rte_free(maps[map_idx].path); > +fail0: > + rte_free(uio_res); > + return -1; > } > -- David Marchand