From: Barbara Skobiej <barbara.skob...@intel.com>

One of the bit shifts in MAC hash calculation triggers a static analysis
warning about a potential overflow. Fix the data type to avoid this.

Fixes: 8cb7c57d9b3c ("net/igc: support device initialization")
Cc: sta...@dpdk.org

Signed-off-by: Barbara Skobiej <barbara.skob...@intel.com>
Signed-off-by: Anatoly Burakov <anatoly.bura...@intel.com>
---
 drivers/net/intel/igc/base/igc_mac.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/intel/igc/base/igc_mac.c 
b/drivers/net/intel/igc/base/igc_mac.c
index c69f8ac73b..cfb74a6443 100644
--- a/drivers/net/intel/igc/base/igc_mac.c
+++ b/drivers/net/intel/igc/base/igc_mac.c
@@ -539,8 +539,10 @@ u32 igc_hash_mc_addr_generic(struct igc_hw *hw, u8 
*mc_addr)
                break;
        }
 
-       hash_value = hash_mask & (((mc_addr[4] >> (8 - bit_shift)) |
-                                 (((u16)mc_addr[5]) << bit_shift)));
+       hash_value = (u32)mc_addr[4];
+       hash_value = hash_value >> (8 - bit_shift);
+       hash_value |= (((u32)mc_addr[5]) << bit_shift);
+       hash_value &= hash_mask;
 
        return hash_value;
 }
-- 
2.43.5

Reply via email to