octeontx2-af: Fix potential integer overflow on shift of a int
Subsystems (4)
PATCH 1/1 octeontx2-af: Fix potential integer overflow on shift of a int
The left shift of int 32 bit integer constant 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.
--- drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c +1 -1
@@ -2411,7 +2411,7 @@ static int nix_smq_flush(struct rvu *rvu, int blkaddr, NIX_AF_TL3_TL2X_LINKX_CFG(tl2_tl3_link_schq, link));if (!(cfg &BIT_ULL (12 )))continue ; - bmap |= (1 << i); + bmap |=BIT_ULL (i); cfg &= ~BIT_ULL (12 );rvu_write64 (rvu, blkaddr,NIX_AF_TL3_TL2X_LINKX_CFG (tl2_tl3_link_schq, link), cfg);
Signature · 1 line
2.39.5
Quoted 16 lines · Colin Ian King
The left shift of int 32 bit integer constant 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_ULLmacro instead.Fixes 019aba04f08c ("octeontx2-af: Modify SMQ flush sequence to drop packets")Signed-off-by Colin Ian King <[email protected]>--- drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c +0
-0
drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c static int nix_smq_flush(struct rvu *rvu, int blkaddr, · line 2414
Quoted 5 lines
drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c +1
-1@@ -2411,7 +2411,7 @@ static int nix_smq_flush(struct rvu *rvu, int blkaddr, NIX_AF_TL3_TL2X_LINKX_CFG(tl2_tl3_link_schq, link));if (!(cfg &BIT_ULL (12 )))continue ; - bmap |= (1 << i); + bmap |=BIT_ULL (i);
There is a similar issue in the next loop. Could you fix that as well?
regards,
dan carpenter