diff options
author | Tal Gilboa <talgi@mellanox.com> | 2018-03-29 13:53:52 +0300 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2018-03-30 19:56:22 +0300 |
commit | f97c3dc3c0e8d23a5c4357d182afeef4c67f5c33 (patch) | |
tree | da900e635b115f6653c8bf6878295f0aa1b3443d /include | |
parent | 52a9692a43b8cbca179d2dd02e714df6f1197932 (diff) | |
download | linux-f97c3dc3c0e8d23a5c4357d182afeef4c67f5c33.tar.xz |
net/dim: Fix int overflow
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>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/net_dim.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/include/linux/net_dim.h b/include/linux/net_dim.h index bebeaad897cc..29ed8fd6379a 100644 --- a/include/linux/net_dim.h +++ b/include/linux/net_dim.h @@ -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) |