[PATCH] [bionic] net/mlx5e: Fix int overflow

Talat Batheesh talatb at mellanox.com
Thu Apr 12 06:42:56 UTC 2018


BugLink: http://bugs.launchpad.net/bugs/1763269

When calculating difference between samples, the values
are multiplied by 100. Large values may cause int overflow
when multiplied (usually on first iteration).
Fixed by forcing 100 to be of type unsigned long.

This patch exist in upstream 4.16 under net_dim.h library.
It need to be adjusted to the 4.15 kernel code location.

Fixes: 4c4dbb4a7363 ("net/mlx5e: Move dynamic interrupt coalescing code to include/linux")
Signed-off-by: Talat Batheesh <talatb at mellanox.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/en_rx_am.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rx_am.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rx_am.c
index b69a705..c362b93 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_rx_am.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rx_am.c
@@ -188,7 +188,7 @@ static void mlx5e_am_exit_parking(struct mlx5e_rx_am *am)
 }
 
 #define IS_SIGNIFICANT_DIFF(val, ref) \
-	(((100 * abs((val) - (ref))) / (ref)) > 10) /* more than 10% difference */
+	(((100UL * abs((val) - (ref))) / (ref)) > 10) /* more than 10% difference */
 
 static int mlx5e_am_stats_compare(struct mlx5e_rx_am_stats *curr,
 				  struct mlx5e_rx_am_stats *prev)
-- 
2.7.5





More information about the kernel-team mailing list