Skip to content

Commit e58edaa

Browse files
talatbdavem330
authored andcommitted
net/mlx5e: Fix fixpoint divide exception in mlx5e_am_stats_compare
Helmut reported a bug about division by zero while running traffic and doing physical cable pull test. When the cable unplugged the ppms become zero, so when dividing the current ppms by the previous ppms in the next dim iteration there is division by zero. This patch prevent this division for both ppms and epms. Fixes: c3164d2 ("net/mlx5e: Added BW check for DIM decision mechanism") Reported-by: Helmut Grauer <helmut.grauer@de.ibm.com> Signed-off-by: Talat Batheesh <talatb@mellanox.com> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent ec835f8 commit e58edaa

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

drivers/net/ethernet/mellanox/mlx5/core/en_rx_am.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,15 @@ static int mlx5e_am_stats_compare(struct mlx5e_rx_am_stats *curr,
201201
return (curr->bpms > prev->bpms) ? MLX5E_AM_STATS_BETTER :
202202
MLX5E_AM_STATS_WORSE;
203203

204+
if (!prev->ppms)
205+
return curr->ppms ? MLX5E_AM_STATS_BETTER :
206+
MLX5E_AM_STATS_SAME;
207+
204208
if (IS_SIGNIFICANT_DIFF(curr->ppms, prev->ppms))
205209
return (curr->ppms > prev->ppms) ? MLX5E_AM_STATS_BETTER :
206210
MLX5E_AM_STATS_WORSE;
211+
if (!prev->epms)
212+
return MLX5E_AM_STATS_SAME;
207213

208214
if (IS_SIGNIFICANT_DIFF(curr->epms, prev->epms))
209215
return (curr->epms < prev->epms) ? MLX5E_AM_STATS_BETTER :

0 commit comments

Comments
 (0)