Skip to contentSkip to conversation

i40e: fix unintended sign extension

PATCH Applied Jingjing Wu 3 participants 3 messages Dec 15, 2015 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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")
---
 drivers/net/i40e/i40e_fdir.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/i40e/i40e_fdir.c +1 -1
index 43a39ec..9ad6981 100644
@@ -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);
 
Signature · 1 line
2.4.0
Acked-by on v1 1/1
#1 lore raw
Quoted 14 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Jingjing Wu
Sent: Tuesday, December 15, 2015 4:23 PM
To: [email protected]
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.

Quoted 2 lines
Fixes 88ebc2b7f976 ("i40e: extend flow director to support VF")
#2 lore raw
Quoted 8 lines

Coverity issue reported like

Quoted 7 lines

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.

Quoted 4 lines
Quoted 2 lines
Fixes 88ebc2b7f976 ("i40e: extend flow director to support VF")

Applied, thanks