From: Slawomir Mrozowicz <slawomirx.mrozowicz@intel.com>
To: olivier.matz@6wind.com
Cc: dev@dpdk.org, Slawomir Mrozowicz <slawomirx.mrozowicz@intel.com>
Subject: [dpdk-dev] [PATCH v2] rte mempool: division or modulo by zero
Date: Thu, 19 May 2016 14:36:35 +0200 [thread overview]
Message-ID: <1463661395-6979-1-git-send-email-slawomirx.mrozowicz@intel.com> (raw)
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 <slawomirx.mrozowicz@intel.com>
---
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
next reply other threads:[~2016-05-19 12:31 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-19 12:36 Slawomir Mrozowicz [this message]
2016-05-23 11:28 ` Olivier Matz
2016-05-24 9:07 ` Thomas Monjalon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1463661395-6979-1-git-send-email-slawomirx.mrozowicz@intel.com \
--to=slawomirx.mrozowicz@intel.com \
--cc=dev@dpdk.org \
--cc=olivier.matz@6wind.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).