From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tetsuya Mukawa Subject: Re: [PATCH] eal: Fix resource leak of pci_uio_map_secondary() Date: Thu, 16 Jun 2016 11:03:44 +0900 Message-ID: References: <1465961172-28253-1-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" , "Mcnamara, John" , michalx.k.jastrzebski@intel.com To: David Marchand Return-path: Received: from mail-pa0-f47.google.com (mail-pa0-f47.google.com [209.85.220.47]) by dpdk.org (Postfix) with ESMTP id 57260C3D4 for ; Thu, 16 Jun 2016 04:03:48 +0200 (CEST) Received: by mail-pa0-f47.google.com with SMTP id hl6so12900745pac.2 for ; Wed, 15 Jun 2016 19:03:48 -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 2016/06/15 23:45, David Marchand wrote: > Hello Tetsuya, > > On Wed, Jun 15, 2016 at 5:26 AM, Tetsuya Mukawa wrote: >> If pci_map_resource() succeeds but mapped address is different from an >> address primary process mapped, this should be error. >> Then the address secondary process mapped should be freed. >> >> Signed-off-by: Tetsuya Mukawa > > The title should not contain the function name. Hi David, Thanks, I will change the title of all patches. > > >> --- >> lib/librte_eal/common/eal_common_pci_uio.c | 3 +++ >> 1 file changed, 3 insertions(+) >> >> diff --git a/lib/librte_eal/common/eal_common_pci_uio.c b/lib/librte_eal/common/eal_common_pci_uio.c >> index f062e81..e718643 100644 >> --- a/lib/librte_eal/common/eal_common_pci_uio.c >> +++ b/lib/librte_eal/common/eal_common_pci_uio.c >> @@ -85,6 +85,9 @@ pci_uio_map_secondary(struct rte_pci_device *dev) >> "Cannot mmap device resource file %s to address: %p\n", >> uio_res->maps[i].path, >> uio_res->maps[i].addr); >> + if (mapaddr != MAP_FAILED) >> + pci_unmap_resource(mapaddr, >> + (size_t)uio_res->maps[i].size); >> return -1; >> } >> } > > What of the previous mappings that might have succeeded earlier in this loop ? I will unmap all addresses mapped before. Thanks, Tetsuya