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 <zhangk.zhangkun@huawei.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
This commit is contained in:
Zhangkun 2014-08-19 11:51:11 +08:00 committed by Thomas Monjalon
parent 844083c46a
commit f20a47ff97

View File

@ -311,11 +311,14 @@ eal_hugepage_info_init(void)
/* if blocking lock failed */ /* if blocking lock failed */
if (flock(hpi->lock_descriptor, LOCK_EX) == -1) { if (flock(hpi->lock_descriptor, LOCK_EX) == -1) {
RTE_LOG(CRIT, EAL, "Failed to lock hugepage directory!\n"); RTE_LOG(CRIT, EAL, "Failed to lock hugepage directory!\n");
closedir(dir);
return -1; return -1;
} }
/* clear out the hugepages dir from unused pages */ /* clear out the hugepages dir from unused pages */
if (clear_hugedir(hpi->hugedir) == -1) if (clear_hugedir(hpi->hugedir) == -1) {
closedir(dir);
return -1; return -1;
}
/* for now, put all pages into socket 0, /* for now, put all pages into socket 0,
* later they will be sorted */ * later they will be sorted */