Skip to content

Commit 637c4f6

Browse files
ColinIanKingPaolo Abeni
authored andcommitted
octeontx2-af: Fix potential integer overflows on integer shifts
The left shift int 32 bit integer constants 1 is evaluated using 32 bit arithmetic and then assigned to a 64 bit unsigned integer. In the case where the shift is 32 or more this can lead to an overflow. Avoid this by shifting using the BIT_ULL macro instead. Fixes: 019aba0 ("octeontx2-af: Modify SMQ flush sequence to drop packets") Signed-off-by: Colin Ian King <[email protected]> Reviewed-by: Dan Carpenter <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
1 parent 1cff6ff commit 637c4f6

File tree

1 file changed

+2
-2
lines changed
  • drivers/net/ethernet/marvell/octeontx2/af

1 file changed

+2
-2
lines changed

drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2411,7 +2411,7 @@ static int nix_smq_flush(struct rvu *rvu, int blkaddr,
24112411
NIX_AF_TL3_TL2X_LINKX_CFG(tl2_tl3_link_schq, link));
24122412
if (!(cfg & BIT_ULL(12)))
24132413
continue;
2414-
bmap |= (1 << i);
2414+
bmap |= BIT_ULL(i);
24152415
cfg &= ~BIT_ULL(12);
24162416
rvu_write64(rvu, blkaddr,
24172417
NIX_AF_TL3_TL2X_LINKX_CFG(tl2_tl3_link_schq, link), cfg);
@@ -2432,7 +2432,7 @@ static int nix_smq_flush(struct rvu *rvu, int blkaddr,
24322432

24332433
/* Set NIX_AF_TL3_TL2_LINKX_CFG[ENA] for the TL3/TL2 queue */
24342434
for (i = 0; i < (rvu->hw->cgx_links + rvu->hw->lbk_links); i++) {
2435-
if (!(bmap & (1 << i)))
2435+
if (!(bmap & BIT_ULL(i)))
24362436
continue;
24372437
cfg = rvu_read64(rvu, blkaddr,
24382438
NIX_AF_TL3_TL2X_LINKX_CFG(tl2_tl3_link_schq, link));

0 commit comments

Comments
 (0)