From: Zhangkun Date: Tue, 19 Aug 2014 03:51:11 +0000 (+0800) Subject: eal: fix memory leak in hugepage error cases X-Git-Tag: spdx-start~10449 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=f20a47ff97da3910529ad4d979d7a6e256cf0a0c;p=dpdk.git 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 --- 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 */