From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Marchand Subject: Re: [PATCH] eal: Fix resource leak of pci_uio_map_secondary() Date: Wed, 15 Jun 2016 16:45:25 +0200 Message-ID: References: <1465961172-28253-1-git-send-email-mukawa@igel.co.jp> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Cc: "dev@dpdk.org" , "Mcnamara, John" , michalx.k.jastrzebski@intel.com To: Tetsuya Mukawa Return-path: Received: from mail-lf0-f47.google.com (mail-lf0-f47.google.com [209.85.215.47]) by dpdk.org (Postfix) with ESMTP id 39D92C6FE for ; Wed, 15 Jun 2016 16:45:45 +0200 (CEST) Received: by mail-lf0-f47.google.com with SMTP id j7so15444445lfg.1 for ; Wed, 15 Jun 2016 07:45:45 -0700 (PDT) In-Reply-To: <1465961172-28253-1-git-send-email-mukawa@igel.co.jp> 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" 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. > --- > 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 ? -- David Marchand