From 125e39139b5f2854fb301123de3705049d1f9d68 Mon Sep 17 00:00:00 2001 From: Slawomir Mrozowicz Date: Thu, 19 May 2016 14:36:35 +0200 Subject: [PATCH] mempool: avoid division by zero In function call rte_mempool_xmem_size, division by expression total_size which may be zero has undefined behavior. Coverity issue: 13243 Fixes: 148f963fb532 ("xen: core library changes") Signed-off-by: Slawomir Mrozowicz Acked-by: Olivier Matz --- lib/librte_mempool/rte_mempool.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c index 1ab670118b..b54de438a9 100644 --- a/lib/librte_mempool/rte_mempool.c +++ b/lib/librte_mempool/rte_mempool.c @@ -239,6 +239,9 @@ rte_mempool_xmem_size(uint32_t elt_num, size_t total_elt_sz, uint32_t pg_shift) { size_t obj_per_page, pg_num, pg_sz; + if (total_elt_sz == 0) + return 0; + if (pg_shift == 0) return total_elt_sz * elt_num; -- 2.20.1