DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH v2] rte mempool: division or modulo by zero
@ 2016-05-19 12:36 Slawomir Mrozowicz
  2016-05-23 11:28 ` Olivier Matz
  0 siblings, 1 reply; 3+ messages in thread
From: Slawomir Mrozowicz @ 2016-05-19 12:36 UTC (permalink / raw)
  To: olivier.matz; +Cc: dev, Slawomir Mrozowicz

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dpdk-dev] [PATCH v2] rte mempool: division or modulo by zero
  2016-05-19 12:36 [dpdk-dev] [PATCH v2] rte mempool: division or modulo by zero Slawomir Mrozowicz
@ 2016-05-23 11:28 ` Olivier Matz
  2016-05-24  9:07   ` Thomas Monjalon
  0 siblings, 1 reply; 3+ messages in thread
From: Olivier Matz @ 2016-05-23 11:28 UTC (permalink / raw)
  To: Slawomir Mrozowicz; +Cc: dev



On 05/19/2016 02:36 PM, Slawomir Mrozowicz wrote:
> 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>

Acked-by: Olivier Matz <olivier.matz@6wind.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dpdk-dev] [PATCH v2] rte mempool: division or modulo by zero
  2016-05-23 11:28 ` Olivier Matz
@ 2016-05-24  9:07   ` Thomas Monjalon
  0 siblings, 0 replies; 3+ messages in thread
From: Thomas Monjalon @ 2016-05-24  9:07 UTC (permalink / raw)
  To: Slawomir Mrozowicz; +Cc: dev, Olivier Matz

Please take care of the title.
Here you know it is not a modulo but you keep copying the coverity message.
It is fixed to "mempool: avoid division by zero"

2016-05-23 13:28, Olivier Matz:
> On 05/19/2016 02:36 PM, Slawomir Mrozowicz wrote:
> > 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.

Please prefer this format instead of the first 2 lines:

Coverity issue: 13243
> > Fixes: 148f963fb532 ("xen: core library changes")
> > 
> > Signed-off-by: Slawomir Mrozowicz <slawomirx.mrozowicz@intel.com>
> 
> Acked-by: Olivier Matz <olivier.matz@6wind.com>

Applied, thanks

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-05-24  9:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-19 12:36 [dpdk-dev] [PATCH v2] rte mempool: division or modulo by zero Slawomir Mrozowicz
2016-05-23 11:28 ` Olivier Matz
2016-05-24  9:07   ` Thomas Monjalon

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).