DPDK patches and discussions
 help / color / mirror / Atom feed
From: Slawomir Mrozowicz <slawomirx.mrozowicz@intel.com>
To: helin.zhang@intel.com, jingjing.wu@intel.com
Cc: dev@dpdk.org, Slawomir Mrozowicz <slawomirx.mrozowicz@intel.com>
Subject: [dpdk-dev] [PATCH] i40e: unintended sign extension
Date: Fri, 20 May 2016 15:03:36 +0200	[thread overview]
Message-ID: <1463749416-7658-1-git-send-email-slawomirx.mrozowicz@intel.com> (raw)

Suspicious implicit sign extension: pf->fdir.match_counter_index
with type unsigned short (16 bits, unsigned) is promoted in
pf->fdir.match_counter_index << 20 to type int (32 bits, signed),
then sign-extended to type unsigned long (64 bits, unsigned).
If pf->fdir.match_counter_index << 20 is greater than 0x7FFFFFFF,
the upper bits of the result will all be 1.
To fix the issue set explicit cast uint32_t of pf->fdir.match_counter_index.

Fixes: 05999aab4ca6 ("i40e: add or delete flow director")
Coverity ID 13315

Signed-off-by: Slawomir Mrozowicz <slawomirx.mrozowicz@intel.com>
---
 drivers/net/i40e/i40e_fdir.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/i40e/i40e_fdir.c b/drivers/net/i40e/i40e_fdir.c
index 8aa41e5..66ef83f 100644
--- a/drivers/net/i40e/i40e_fdir.c
+++ b/drivers/net/i40e/i40e_fdir.c
@@ -1141,7 +1141,8 @@ i40e_fdir_filter_programming(struct i40e_pf *pf,
 	fdirdp->dtype_cmd_cntindex |=
 			rte_cpu_to_le_32(I40E_TXD_FLTR_QW1_CNT_ENA_MASK);
 	fdirdp->dtype_cmd_cntindex |=
-			rte_cpu_to_le_32((pf->fdir.match_counter_index <<
+			rte_cpu_to_le_32(
+			((uint32_t)pf->fdir.match_counter_index <<
 			I40E_TXD_FLTR_QW1_CNTINDEX_SHIFT) &
 			I40E_TXD_FLTR_QW1_CNTINDEX_MASK);
 
-- 
1.9.1

             reply	other threads:[~2016-05-20 12:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-20 13:03 Slawomir Mrozowicz [this message]
2016-06-09 15:14 ` Bruce Richardson

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=1463749416-7658-1-git-send-email-slawomirx.mrozowicz@intel.com \
    --to=slawomirx.mrozowicz@intel.com \
    --cc=dev@dpdk.org \
    --cc=helin.zhang@intel.com \
    --cc=jingjing.wu@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).