From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sergio Gonzalez Monroy Subject: Re: [PATCH v3] eal/linuxapp: fix resource leak Date: Thu, 30 Jun 2016 14:31:24 +0100 Message-ID: <3f3b0684-4834-b855-bc8a-e386d2ac7ff1@intel.com> References: <1462982465-129762-1-git-send-email-danielx.t.mrzyglod@intel.com> <1466614235-121524-1-git-send-email-danielx.t.mrzyglod@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Cc: dev@dpdk.org To: Daniel Mrzyglod , david.marchand@6wind.com Return-path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id B29072B8D for ; Thu, 30 Jun 2016 15:32:08 +0200 (CEST) In-Reply-To: <1466614235-121524-1-git-send-email-danielx.t.mrzyglod@intel.com> 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 22/06/2016 17:50, Daniel Mrzyglod wrote: > This patch fix all cases to do proper handle all munmap if pointer > of hugepage is not NULL which prohibits resource leak. I would reword the above commit to something like: Current code does not munmap 'hugepage' mapping (hugepage info file) on function exit, leaking resources. > Coverity issue: 97920 > Fixes: b6a468ad41d5 ("memory: add --socket-mem option") > > Signed-off-by: Daniel Mrzyglod > --- > lib/librte_eal/linuxapp/eal/eal_memory.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/lib/librte_eal/linuxapp/eal/eal_memory.c b/lib/librte_eal/linuxapp/eal/eal_memory.c > index 9251a5b..9b0d39a 100644 > --- a/lib/librte_eal/linuxapp/eal/eal_memory.c > +++ b/lib/librte_eal/linuxapp/eal/eal_memory.c > @@ -1051,7 +1051,7 @@ int > rte_eal_hugepage_init(void) > { > struct rte_mem_config *mcfg; > - struct hugepage_file *hugepage, *tmp_hp = NULL; > + struct hugepage_file *hugepage = NULL, *tmp_hp = NULL; > struct hugepage_info used_hp[MAX_HUGEPAGE_SIZES]; > > uint64_t memory[RTE_MAX_NUMA_NODES]; > @@ -1367,13 +1367,15 @@ rte_eal_hugepage_init(void) > "of memory.\n", > i, nr_hugefiles, RTE_STR(CONFIG_RTE_MAX_MEMSEG), > RTE_MAX_MEMSEG); > - return -ENOMEM; > + goto fail; > } > I missed this but we should also munmap 'hugepage' on successful function exit. Sergio > return 0; > > fail: > free(tmp_hp); > + if (hugepage != NULL) > + munmap(hugepage, nr_hugefiles * sizeof(struct hugepage_file)); > return -1; > } >