Skip to content

Commit

Permalink
net/i40e: fix unintentional integer overflow
Browse files Browse the repository at this point in the history
[ upstream commit df58076 ]

Cast 1 to type uint64_t to avoid overflow.

CID 375812 (#1 of 1):
Unintentional integer overflow (OVERFLOW_BEFORE_WIDEN)
overflow_before_widen: Potentially overflowing expression 1 << 2 * i + 1
with type int (32 bits, signed) is evaluated using 32-bit arithmetic, and
then used in a context that expects an expression of type uint64_t
(64 bits, unsigned).

Coverity issue: 375812
Fixes: 5fec01c ("net/i40e: support Linux VF to configure IRQ link list")

Signed-off-by: Steve Yang <stevex.yang@intel.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
  • Loading branch information
Steve Yang authored and bluca committed Feb 28, 2022
1 parent 073988b commit 2d1c255
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions drivers/net/i40e/i40e_pf.c
Expand Up @@ -17,6 +17,7 @@
#include <rte_ethdev_driver.h>
#include <rte_malloc.h>
#include <rte_memcpy.h>
#include <rte_bitops.h>

#include "i40e_logs.h"
#include "base/i40e_prototype.h"
Expand Down Expand Up @@ -597,14 +598,14 @@ i40e_pf_config_irq_link_list(struct i40e_pf_vf *vf,
tempmap = vvm->rxq_map;
for (i = 0; i < sizeof(vvm->rxq_map) * BITS_PER_CHAR; i++) {
if (tempmap & 0x1)
linklistmap |= (1 << (2 * i));
linklistmap |= RTE_BIT64(2 * i);
tempmap >>= 1;
}

tempmap = vvm->txq_map;
for (i = 0; i < sizeof(vvm->txq_map) * BITS_PER_CHAR; i++) {
if (tempmap & 0x1)
linklistmap |= (1 << (2 * i + 1));
linklistmap |= RTE_BIT64(2 * i + 1);
tempmap >>= 1;
}

Expand Down

0 comments on commit 2d1c255

Please sign in to comment.