DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] i40e: fix unintended sign extension
@ 2015-12-15 16:23 Jingjing Wu
  2015-12-15 17:01 ` Mcnamara, John
  0 siblings, 1 reply; 3+ messages in thread
From: Jingjing Wu @ 2015-12-15 16:23 UTC (permalink / raw)
  To: dev

Coverity issue reported like
CID 119268 (#1 of 1): Unintended sign extension
(SIGN_EXTENSION)sign_extension: Suspicious implicit sign extension:
vsi_id with type unsigned short (16 bits, unsigned) is promoted in
vsi_id << 23 to type int (32 bits, signed), then sign-extended to type
unsigned long (64 bits, unsigned). If vsi_id << 23 is greater than
0x7FFFFFFF, the upper bits of the result will all be 1.

Fixes: 88ebc2b7f976 ("i40e: extend flow director to support VF")
Signed-off-by: Jingjing Wu <jingjing.wu@intel.com>
---
 drivers/net/i40e/i40e_fdir.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/i40e/i40e_fdir.c b/drivers/net/i40e/i40e_fdir.c
index 43a39ec..9ad6981 100644
--- a/drivers/net/i40e/i40e_fdir.c
+++ b/drivers/net/i40e/i40e_fdir.c
@@ -1091,7 +1091,7 @@ i40e_fdir_filter_programming(struct i40e_pf *pf,
 		/* Use LAN VSI Id by default */
 		vsi_id = pf->main_vsi->vsi_id;
 	fdirdp->qindex_flex_ptype_vsi |=
-		rte_cpu_to_le_32((vsi_id <<
+		rte_cpu_to_le_32(((uint32_t)vsi_id <<
 				  I40E_TXD_FLTR_QW0_DEST_VSI_SHIFT) &
 				  I40E_TXD_FLTR_QW0_DEST_VSI_MASK);
 
-- 
2.4.0

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

* Re: [dpdk-dev] [PATCH] i40e: fix unintended sign extension
  2015-12-15 16:23 [dpdk-dev] [PATCH] i40e: fix unintended sign extension Jingjing Wu
@ 2015-12-15 17:01 ` Mcnamara, John
  2015-12-15 17:07   ` Thomas Monjalon
  0 siblings, 1 reply; 3+ messages in thread
From: Mcnamara, John @ 2015-12-15 17:01 UTC (permalink / raw)
  To: Wu, Jingjing, dev

> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Jingjing Wu
> Sent: Tuesday, December 15, 2015 4:23 PM
> To: dev@dpdk.org
> Subject: [dpdk-dev] [PATCH] i40e: fix unintended sign extension
> 
> Coverity issue reported like
> CID 119268 (#1 of 1): Unintended sign extension
> (SIGN_EXTENSION)sign_extension: Suspicious implicit sign extension:
> vsi_id with type unsigned short (16 bits, unsigned) is promoted in vsi_id
> << 23 to type int (32 bits, signed), then sign-extended to type unsigned
> long (64 bits, unsigned). If vsi_id << 23 is greater than 0x7FFFFFFF, the
> upper bits of the result will all be 1.
> 
> Fixes: 88ebc2b7f976 ("i40e: extend flow director to support VF")
> Signed-off-by: Jingjing Wu <jingjing.wu@intel.com>

Acked-by: John McNamara <john.mcnamara@intel.com>

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

* Re: [dpdk-dev] [PATCH] i40e: fix unintended sign extension
  2015-12-15 17:01 ` Mcnamara, John
@ 2015-12-15 17:07   ` Thomas Monjalon
  0 siblings, 0 replies; 3+ messages in thread
From: Thomas Monjalon @ 2015-12-15 17:07 UTC (permalink / raw)
  To: Wu, Jingjing; +Cc: dev

 > Coverity issue reported like
> > CID 119268 (#1 of 1): Unintended sign extension
> > (SIGN_EXTENSION)sign_extension: Suspicious implicit sign extension:
> > vsi_id with type unsigned short (16 bits, unsigned) is promoted in vsi_id
> > << 23 to type int (32 bits, signed), then sign-extended to type unsigned
> > long (64 bits, unsigned). If vsi_id << 23 is greater than 0x7FFFFFFF, the
> > upper bits of the result will all be 1.
> > 
> > Fixes: 88ebc2b7f976 ("i40e: extend flow director to support VF")
> > Signed-off-by: Jingjing Wu <jingjing.wu@intel.com>
> 
> Acked-by: John McNamara <john.mcnamara@intel.com>

Applied, thanks

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

end of thread, other threads:[~2015-12-15 17:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-15 16:23 [dpdk-dev] [PATCH] i40e: fix unintended sign extension Jingjing Wu
2015-12-15 17:01 ` Mcnamara, John
2015-12-15 17: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).