From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 63E6F9AAB for ; Thu, 19 May 2016 14:31:15 +0200 (CEST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP; 19 May 2016 05:31:14 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,334,1459839600"; d="scan'208";a="984508207" Received: from gklab-246-018.igk.intel.com (HELO stargo) ([10.217.246.18]) by fmsmga002.fm.intel.com with SMTP; 19 May 2016 05:31:13 -0700 Received: by stargo (sSMTP sendmail emulation); Thu, 19 May 2016 14:36:37 +0200 From: Slawomir Mrozowicz To: olivier.matz@6wind.com Cc: dev@dpdk.org, Slawomir Mrozowicz Date: Thu, 19 May 2016 14:36:35 +0200 Message-Id: <1463661395-6979-1-git-send-email-slawomirx.mrozowicz@intel.com> X-Mailer: git-send-email 1.9.1 Subject: [dpdk-dev] [PATCH v2] rte mempool: division or modulo by zero X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 May 2016 12:31:15 -0000 Fix issue reported by Coverity. Coverity ID 13243: Division or modulo by zero In function call rte_mempool_xmem_size, division by expression total_size which may be zero has undefined behavior. Fixes: 148f963fb532 ("xen: core library changes") Signed-off-by: Slawomir Mrozowicz --- 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 1ab6701..b54de43 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; -- 1.9.1