From 43b194b43344b262b00f6c8a24443b46ed82009b Mon Sep 17 00:00:00 2001 From: Sergio Gonzalez Monroy Date: Thu, 9 Jun 2016 09:19:47 +0100 Subject: [PATCH] mempool: fix local cache initialization The mempool local cache was not initialized properly leading to undefined behavior in cases where the allocated memory was used previously and left with data. Fixes: 213af31e0960 ("mempool: reduce structure size if no cache needed") Signed-off-by: Sergio Gonzalez Monroy Acked-by: Olivier Matz --- lib/librte_mempool/rte_mempool.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c index 22a564570d..af71edde01 100644 --- a/lib/librte_mempool/rte_mempool.c +++ b/lib/librte_mempool/rte_mempool.c @@ -787,7 +787,7 @@ rte_mempool_create_empty(const char *name, unsigned n, unsigned elt_size, /* init the mempool structure */ mp = mz->addr; - memset(mp, 0, sizeof(*mp)); + memset(mp, 0, MEMPOOL_HEADER_SIZE(mp, cache_size)); ret = snprintf(mp->name, sizeof(mp->name), "%s", name); if (ret < 0 || ret >= (int)sizeof(mp->name)) { rte_errno = ENAMETOOLONG; -- 2.20.1