From: Slawomir Mrozowicz Date: Fri, 20 May 2016 13:03:36 +0000 (+0200) Subject: net/i40e: fix unintended sign extension X-Git-Tag: spdx-start~6550 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=6e15a19c625f6f6f86149d32145fcd2b525cb2f6;p=dpdk.git net/i40e: fix unintended sign extension 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 explicitly cast pf->fdir.match_counter_index to uint32_t. Coverity issue: 13315 Fixes: 05999aab4ca6 ("i40e: add or delete flow director") Signed-off-by: Slawomir Mrozowicz Acked-by: Bruce Richardson --- diff --git a/drivers/net/i40e/i40e_fdir.c b/drivers/net/i40e/i40e_fdir.c index efbcd185a7..f65c4110bf 100644 --- a/drivers/net/i40e/i40e_fdir.c +++ b/drivers/net/i40e/i40e_fdir.c @@ -1143,7 +1143,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);