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

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Talat Batheesh
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 <[hidden email]>
---
 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


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

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

Seth Forshee
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 <[hidden email]>

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.

--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team