From: Anatoly Burakov Date: Thu, 21 Dec 2017 18:07:07 +0000 (+0000) Subject: memzone: fix leak on allocation error X-Git-Tag: spdx-start~719 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=db22d31a79733f08e974f134c883361fd8641984;p=dpdk.git memzone: fix leak on allocation error We check if there's space in config after we allocated the memzone, but if there isn't, we never free it back. This patch adds memzone free if there's no room in memzone config. Fixes: ff909fe21f0a ("mem: introduce memzone freeing") Cc: stable@dpdk.org Signed-off-by: Anatoly Burakov --- diff --git a/lib/librte_eal/common/eal_common_memzone.c b/lib/librte_eal/common/eal_common_memzone.c index d26e385615..1ab3ade2d1 100644 --- a/lib/librte_eal/common/eal_common_memzone.c +++ b/lib/librte_eal/common/eal_common_memzone.c @@ -208,7 +208,7 @@ memzone_reserve_aligned_thread_unsafe(const char *name, size_t len, return NULL; } - const struct malloc_elem *elem = malloc_elem_from_data(mz_addr); + struct malloc_elem *elem = malloc_elem_from_data(mz_addr); /* fill the zone in config */ mz = get_next_free_memzone(); @@ -216,6 +216,7 @@ memzone_reserve_aligned_thread_unsafe(const char *name, size_t len, if (mz == NULL) { RTE_LOG(ERR, EAL, "%s(): Cannot find free memzone but there is room " "in config!\n", __func__); + malloc_elem_free(elem); rte_errno = ENOSPC; return NULL; }