Commit f97c3dc3 authored by Tal Gilboa's avatar Tal Gilboa Committed by David S. Miller

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: 4c4dbb4a ("net/mlx5e: Move dynamic interrupt coalescing code to include/linux")
Signed-off-by: default avatarTal Gilboa <talgi@mellanox.com>
Reviewed-by: default avatarAndy Gospodarek <gospo@broadcom.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 52a9692a
...@@ -231,7 +231,7 @@ static inline void net_dim_exit_parking(struct net_dim *dim) ...@@ -231,7 +231,7 @@ static inline void net_dim_exit_parking(struct net_dim *dim)
} }
#define IS_SIGNIFICANT_DIFF(val, ref) \ #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, static inline int net_dim_stats_compare(struct net_dim_stats *curr,
struct net_dim_stats *prev) struct net_dim_stats *prev)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment