DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] eal/linuxapp: fix resource leak
@ 2016-05-11 16:01 Daniel Mrzyglod
  2016-05-12  7:55 ` Sergio Gonzalez Monroy
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Daniel Mrzyglod @ 2016-05-11 16:01 UTC (permalink / raw)
  To: sergio.gonzalez.monroy, david.marchand; +Cc: dev, Daniel Mrzyglod

Fix issue reported by Coverity.
Coverity ID 97920

munmap structure of hugepage

leaked_storage: Variable hugepage going out of scope leaks the storage
it points to.

The system resource will not be reclaimed and reused, reducing the future
availability of the resource.

In rte_eal_hugepage_init: Leak of memory or pointers to system resources

Fixes: b6a468ad41d5 ("memory: add --socket-mem option")

Signed-off-by: Daniel Mrzyglod <danielx.t.mrzyglod@intel.com>
---
 lib/librte_eal/linuxapp/eal/eal_memory.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib/librte_eal/linuxapp/eal/eal_memory.c b/lib/librte_eal/linuxapp/eal/eal_memory.c
index 5b9132c..cd40cc9 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];
@@ -1374,6 +1374,8 @@ rte_eal_hugepage_init(void)
 
 fail:
 	free(tmp_hp);
+	if (hugepage != NULL)
+		munmap(hugepage, nr_hugefiles * sizeof(struct hugepage_file));
 	return -1;
 }
 
-- 
2.5.5

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2016-07-10 13:29 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-11 16:01 [dpdk-dev] [PATCH] eal/linuxapp: fix resource leak Daniel Mrzyglod
2016-05-12  7:55 ` Sergio Gonzalez Monroy
2016-05-13 10:28   ` Thomas Monjalon
2016-05-12  9:12 ` [dpdk-dev] [PATCH v2] " Daniel Mrzyglod
2016-06-20  9:33   ` Thomas Monjalon
2016-06-22 16:50 ` [dpdk-dev] [PATCH v3] " Daniel Mrzyglod
2016-06-30 13:31   ` Sergio Gonzalez Monroy
2016-07-06 10:44 ` [dpdk-dev] [PATCH v4] " Daniel Mrzyglod
2016-07-06 10:48   ` Sergio Gonzalez Monroy
2016-07-10 13:29     ` Thomas Monjalon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).