diff options
author | Jose Abreu <Jose.Abreu@synopsys.com> | 2019-09-10 17:41:22 +0300 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2019-09-11 11:21:34 +0300 |
commit | 6fa9d691b91ac6e6d8a1e3799d24324a6a70663f (patch) | |
tree | 5722148d11e3955a8ab1814e41edbe29fe6ea3dc | |
parent | e7f13f44c77b68f8c4e6ea77984aa142613a50c9 (diff) | |
download | linux-6fa9d691b91ac6e6d8a1e3799d24324a6a70663f.tar.xz |
net: stmmac: Prevent divide-by-zero
When RX Coalesce settings are set to all zero (which is a valid setting)
we will currently get a divide-by-zero error. Fix it.
Signed-off-by: Jose Abreu <joabreu@synopsys.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 686b82068142..6e44013b20cc 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -3418,7 +3418,9 @@ static inline void stmmac_rx_refill(struct stmmac_priv *priv, u32 queue) stmmac_refill_desc3(priv, rx_q, p); rx_q->rx_count_frames++; - rx_q->rx_count_frames %= priv->rx_coal_frames; + rx_q->rx_count_frames += priv->rx_coal_frames; + if (rx_q->rx_count_frames > priv->rx_coal_frames) + rx_q->rx_count_frames = 0; use_rx_wd = priv->use_riwt && rx_q->rx_count_frames; dma_wmb(); |