From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 7DC99567E for ; Wed, 6 Jul 2016 11:43:41 +0200 (CEST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP; 06 Jul 2016 02:43:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.28,318,1464678000"; d="scan'208";a="1011696983" Received: from gklab-246-025.igk.intel.com (HELO Sent) ([10.217.246.25]) by orsmga002.jf.intel.com with SMTP; 06 Jul 2016 02:43:38 -0700 Received: by Sent (sSMTP sendmail emulation); Wed, 06 Jul 2016 12:45:00 +0200 From: Daniel Mrzyglod To: sergio.gonzalez.monroy@intel.com, david.marchand@6wind.com Cc: dev@dpdk.org, Daniel Mrzyglod Date: Wed, 6 Jul 2016 12:44:53 +0200 Message-Id: <1467801893-73003-1-git-send-email-danielx.t.mrzyglod@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1462982465-129762-1-git-send-email-danielx.t.mrzyglod@intel.com> References: <1462982465-129762-1-git-send-email-danielx.t.mrzyglod@intel.com> Subject: [dpdk-dev] [PATCH v4] eal/linuxapp: fix resource leak 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, 06 Jul 2016 09:43:41 -0000 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 | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/librte_eal/linuxapp/eal/eal_memory.c b/lib/librte_eal/linuxapp/eal/eal_memory.c index 5578c25..b663244 100644 --- a/lib/librte_eal/linuxapp/eal/eal_memory.c +++ b/lib/librte_eal/linuxapp/eal/eal_memory.c @@ -1136,7 +1136,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]; @@ -1479,14 +1479,19 @@ rte_eal_hugepage_init(void) "of memory.\n", i, nr_hugefiles, RTE_STR(CONFIG_RTE_MAX_MEMSEG), RTE_MAX_MEMSEG); - return -ENOMEM; + goto fail; } + munmap(hugepage, nr_hugefiles * sizeof(struct hugepage_file)); + return 0; fail: huge_recover_sigbus(); free(tmp_hp); + if (hugepage != NULL) + munmap(hugepage, nr_hugefiles * sizeof(struct hugepage_file)); + return -1; } -- 2.7.4