From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pd0-f170.google.com (mail-pd0-f170.google.com [209.85.192.170]) by dpdk.org (Postfix) with ESMTP id 570045A8E for ; Fri, 20 Mar 2015 02:53:35 +0100 (CET) Received: by pdbcz9 with SMTP id cz9so93340743pdb.3 for ; Thu, 19 Mar 2015 18:53:34 -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=yRJgxFrpGQamiLt2DMrE40QOiz6Jx9fZAWeiqZ27mrs=; b=ZAk6up87I8ihMuh7d3z/52zIcSYi4sDUcxDJ8WjvF8R3scQM1UvMkKrL7O0aasuPlY Y2dPQdK7tlFTGFcKrINAf7ZdrwO+yV2+7lSqrVzwcQtDPoZdDOikQP2Z41IYAXcyq5l/ b+CmScztcboEb30w28GIYWz4SCpqiR1UGLqYcz4JdEgXZnCH3NOr7Am1xgiZXBpiuduy 6FsV6JIXbeuqUXjCPiuDT2SshBy1roZr8nZUGG8SSETb2J8E3TgFe8u9lytGpNOdlAqB 3P2sL6+lpMhide/Ja1Gn3bELxVUJcGUroQI0pH5nFBmhsSxTtB3tfb6ePSiEgWob/7CS JxUQ== X-Gm-Message-State: ALoCoQlG7ngNgd1gl+Hsr4FIKMA8O0lXF3BAH7EF7tQDe2XPPaoHqECzJcrz1B2SqwXm1inndwDh X-Received: by 10.66.140.39 with SMTP id rd7mr179833451pab.25.1426816414739; Thu, 19 Mar 2015 18:53:34 -0700 (PDT) Received: from [10.16.129.101] (napt.igel.co.jp. [219.106.231.132]) by mx.google.com with ESMTPSA id s17sm5056642pdn.87.2015.03.19.18.53.33 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Mar 2015 18:53:34 -0700 (PDT) Message-ID: <550B7DA0.8000109@igel.co.jp> Date: Fri, 20 Mar 2015 10:53:36 +0900 From: Tetsuya Mukawa User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: David Marchand 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> In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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: Fri, 20 Mar 2015 01:53:35 -0000 On 2015/03/19 0:39, David Marchand wrote: > 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 =3D uio_res->maps; > for (i =3D 0, map_idx =3D 0; i !=3D PCI_MAX_RESOURCE; i++) = { > int fd; > - int fail =3D 0; > > /* skip empty BAR */ > phaddr =3D dev->mem_resource[i].phys_addr; > @@ -347,6 +346,11 @@ pci_uio_map_resource(struct rte_pci_device *de= v) > loc->domain, loc->bus, loc->devid, > loc->function, > i); > > + /* allocate memory to keep path */ > + maps[map_idx].path =3D rte_malloc(NULL, > strlen(devname) + 1, 0); > + if (maps[map_idx].path =3D=3D NULL) > + goto fail0; > + > > > [snip] > > Neither fail0 nor fail1 labels seem to free previous allocations. > Did I miss something ? Hi David, Ah, you are right. I will free all 'maps[i].path' allocated in this function. Thanks, Tetsuya > > [snip] > > + > +fail1: > + rte_free(maps[map_idx].path); > +fail0: > + rte_free(uio_res); > + return -1; > } > > > =20 > > --=20 > David Marchand