Skip to content

Commit 468c2a1

Browse files
Colin Ian Kingdavem330
authored andcommitted
mlxsw: spectrum_trap: fix unintention integer overflow on left shift
Shifting the integer value 1 is evaluated using 32-bit arithmetic and then used in an expression that expects a 64-bit value, so there is potentially an integer overflow. Fix this by using the BIT_ULL macro to perform the shift and avoid the overflow. Addresses-Coverity: ("Unintentional integer overflow") Fixes: 13f2e64 ("mlxsw: spectrum_trap: Add devlink-trap policer support") Signed-off-by: Colin Ian King <[email protected]> Reviewed-by: Ido Schimmel <[email protected]> Tested-by: Ido Schimmel <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 2f5107c commit 468c2a1

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/net/ethernet/mellanox/mlxsw/spectrum_trap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,7 @@ static int mlxsw_sp_trap_policer_bs(u64 burst, u8 *p_burst_size,
643643
{
644644
int bs = fls64(burst) - 1;
645645

646-
if (burst != (1 << bs)) {
646+
if (burst != (BIT_ULL(bs))) {
647647
NL_SET_ERR_MSG_MOD(extack, "Policer burst size is not power of two");
648648
return -EINVAL;
649649
}

0 commit comments

Comments
 (0)