DPDK patches and discussions
 help / color / mirror / Atom feed
From: Daniel Mrzyglod <danielx.t.mrzyglod@intel.com>
To: konstantin.ananyev@intel.com
Cc: dev@dpdk.org, Daniel Mrzyglod <danielx.t.mrzyglod@intel.com>
Subject: [dpdk-dev] [PATCH] app/test_acl: fix division by float zero
Date: Fri, 22 Apr 2016 18:00:50 +0200	[thread overview]
Message-ID: <1461340850-202703-1-git-send-email-danielx.t.mrzyglod@intel.com> (raw)

Fix issue reported by Coverity.
Coverity ID 13240

This could cause an immediate crash or incorrect computation.

In search_ip5tuples: An expression which may be zero is used
as a divisor in floating-point arithmetic.

divide_by_zero: In expression (long double)tm / pkt,
division by expression pkt which may be zero has undefined behavior.

Fixes: 26c057ab6c45 ("acl: new test-acl application")

Signed-off-by: Daniel Mrzyglod <danielx.t.mrzyglod@intel.com>
---
 app/test-acl/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/app/test-acl/main.c b/app/test-acl/main.c
index 0b0c093..d366981 100644
--- a/app/test-acl/main.c
+++ b/app/test-acl/main.c
@@ -901,7 +901,7 @@ search_ip5tuples(__attribute__((unused)) void *arg)
 		"%s  @lcore %u: %" PRIu32 " iterations, %" PRIu64 " pkts, %"
 		PRIu32 " categories, %" PRIu64 " cycles, %#Lf cycles/pkt\n",
 		__func__, lcore, i, pkt, config.run_categories,
-		tm, (long double)tm / pkt);
+		tm, (pkt == 0) ? 0 : (long double)tm / pkt);
 
 	return 0;
 }
-- 
2.5.5

             reply	other threads:[~2016-04-22 14:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-22 16:00 Daniel Mrzyglod [this message]
2016-04-22 15:15 ` Ananyev, Konstantin
2016-04-27 14:14   ` 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=1461340850-202703-1-git-send-email-danielx.t.mrzyglod@intel.com \
    --to=danielx.t.mrzyglod@intel.com \
    --cc=dev@dpdk.org \
    --cc=konstantin.ananyev@intel.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).