From: Andrew Rybchenko Date: Mon, 16 Apr 2018 13:24:30 +0000 (+0100) Subject: mempool: fix leak when no objects are populated X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=25e6755056eaba45921b898b9986af68277ac6ac;p=dpdk.git mempool: fix leak when no objects are populated Fixes: 84121f197187 ("mempool: store memory chunks in a list") Cc: stable@dpdk.org Suggested-by: Olivier Matz Signed-off-by: Andrew Rybchenko Acked-by: Olivier Matz --- diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c index 103c015e57..3b31a55513 100644 --- a/lib/librte_mempool/rte_mempool.c +++ b/lib/librte_mempool/rte_mempool.c @@ -421,12 +421,18 @@ rte_mempool_populate_iova(struct rte_mempool *mp, char *vaddr, } /* not enough room to store one object */ - if (i == 0) - return -EINVAL; + if (i == 0) { + ret = -EINVAL; + goto fail; + } STAILQ_INSERT_TAIL(&mp->mem_list, memhdr, next); mp->nb_mem_chunks++; return i; + +fail: + rte_free(memhdr); + return ret; } int