From: Pablo de Lara Date: Thu, 2 Aug 2018 00:35:04 +0000 (+0100) Subject: mempool: check for zero size creation X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=b2a4654f082b094441125c2dd55c8b80e2aa2c0a;p=dpdk.git mempool: check for zero size creation Currently, a mempool can be created if the number of objects is zero. However, in this scenario, rte_mempool_create should return NULL, as the mempool created is useless otherwise. Signed-off-by: Pablo de Lara Acked-by: Andrew Rybchenko --- diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c index 8c8b9f8097..a24a14887d 100644 --- a/lib/librte_mempool/rte_mempool.c +++ b/lib/librte_mempool/rte_mempool.c @@ -916,6 +916,12 @@ rte_mempool_create_empty(const char *name, unsigned n, unsigned elt_size, mempool_list = RTE_TAILQ_CAST(rte_mempool_tailq.head, rte_mempool_list); + /* asked for zero items */ + if (n == 0) { + rte_errno = EINVAL; + return NULL; + } + /* asked cache too big */ if (cache_size > RTE_MEMPOOL_CACHE_MAX_SIZE || CALC_CACHE_FLUSHTHRESH(cache_size) > n) {