[PATCH v4 007/103] net/ice/base: prevent potential integer overflow

Anatoly Burakov anatoly.burakov at intel.com
Wed Jun 26 13:40:55 CEST 2024


From: Lukasz Plachno <lukasz.plachno at intel.com>

The original bit-shift was made on a 16-bit value which could overflow.
Use 64-bit integer to do bit-shifts instead.

Signed-off-by: Lukasz Plachno <lukasz.plachno at intel.com>
Signed-off-by: Ian Stokes <ian.stokes at intel.com>
---
 drivers/net/ice/base/ice_parser_rt.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ice/base/ice_parser_rt.c b/drivers/net/ice/base/ice_parser_rt.c
index 69655fdd96..50a3d301b0 100644
--- a/drivers/net/ice/base/ice_parser_rt.c
+++ b/drivers/net/ice/base/ice_parser_rt.c
@@ -469,9 +469,9 @@ static void _err_add(struct ice_parser_rt *rt, int idx, bool val)
 {
 	rt->pu.err_msk |= (u16)(1 << idx);
 	if (val)
-		rt->pu.flg_val |= (u16)(1 << idx);
+		rt->pu.flg_val |= (1ULL << idx);
 	else
-		rt->pu.flg_val &= ~(u16)(1 << idx);
+		rt->pu.flg_val &= ~(1ULL << idx);
 
 	ice_debug(rt->psr->hw, ICE_DBG_PARSER, "Pending update for error %d value %d\n",
 		  idx, val);
-- 
2.43.0



More information about the dev mailing list