]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
net/dim: Fix int overflow
authorTal Gilboa <talgi@mellanox.com>
Thu, 29 Mar 2018 10:53:52 +0000 (13:53 +0300)
committerDavid S. Miller <davem@davemloft.net>
Fri, 30 Mar 2018 16:56:22 +0000 (12:56 -0400)
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.

Fixes: 4c4dbb4a7363 ("net/mlx5e: Move dynamic interrupt coalescing code to include/linux")
Signed-off-by: Tal Gilboa <talgi@mellanox.com>
Reviewed-by: Andy Gospodarek <gospo@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/net_dim.h

index bebeaad897cc406d550175603a19a1c15e582942..29ed8fd6379a79f43d887be4fd9a7bfc9a46c897 100644 (file)
@@ -231,7 +231,7 @@ static inline void net_dim_exit_parking(struct net_dim *dim)
 }
 
 #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 inline int net_dim_stats_compare(struct net_dim_stats *curr,
                                        struct net_dim_stats *prev)