diff mbox series

[bionic] net/mlx5e: Fix int overflow

Message ID 1523515376-28554-1-git-send-email-talatb@mellanox.com
State New
Headers show
Series [bionic] net/mlx5e: Fix int overflow | expand

Commit Message

Talat Batheesh April 12, 2018, 6:42 a.m. UTC
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@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/en_rx_am.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Seth Forshee April 12, 2018, 3:48 p.m. UTC | #1
On Thu, Apr 12, 2018 at 09:42:56AM +0300, Talat Batheesh wrote:
> 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@mellanox.com>

Thanks for the patch. There are couple of minor issues, which I've fixed
when applying the patch:

 - Please be sure to keep the author as the original other of the patch.

 - Please be sure to keep the full upstream provenance in place when
   backporting.

The usual way to do this is to use 'git cherry-pick -s -x -e', then
perform the backporting and change the "cherry picked from ..." line to
read "backported from ...".

With those things fixed, applied to bionic/master-next.
diff mbox series

Patch

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)