]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
net: stmmac: Prevent divide-by-zero
authorJose Abreu <Jose.Abreu@synopsys.com>
Tue, 10 Sep 2019 14:41:22 +0000 (16:41 +0200)
committerDavid S. Miller <davem@davemloft.net>
Wed, 11 Sep 2019 08:21:34 +0000 (09:21 +0100)
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>
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c

index 686b820681422bed8d986557d3124c2bcd76780a..6e44013b20ccb5f3fdf3602e64ad0e95c1f5e768 100644 (file)
@@ -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();