From f20a47ff97da3910529ad4d979d7a6e256cf0a0c Mon Sep 17 00:00:00 2001 From: Zhangkun Date: Tue, 19 Aug 2014 11:51:11 +0800 Subject: [PATCH] eal: fix memory leak in hugepage error cases The sysfs directory for hugepages parsing was not closed properly in some error cases. Signed-off-by: Zhangkun Acked-by: Thomas Monjalon --- lib/librte_eal/linuxapp/eal/eal_hugepage_info.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/librte_eal/linuxapp/eal/eal_hugepage_info.c b/lib/librte_eal/linuxapp/eal/eal_hugepage_info.c index b72a205b5a..73d1cdb757 100644 --- a/lib/librte_eal/linuxapp/eal/eal_hugepage_info.c +++ b/lib/librte_eal/linuxapp/eal/eal_hugepage_info.c @@ -311,11 +311,14 @@ eal_hugepage_info_init(void) /* if blocking lock failed */ if (flock(hpi->lock_descriptor, LOCK_EX) == -1) { RTE_LOG(CRIT, EAL, "Failed to lock hugepage directory!\n"); + closedir(dir); return -1; } /* clear out the hugepages dir from unused pages */ - if (clear_hugedir(hpi->hugedir) == -1) + if (clear_hugedir(hpi->hugedir) == -1) { + closedir(dir); return -1; + } /* for now, put all pages into socket 0, * later they will be sorted */ -- 2.20.1