diff options
author | Florian Fainelli <f.fainelli@gmail.com> | 2014-10-10 13:51:52 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-10-10 15:39:15 -0400 |
commit | cf377d886f7944a5ccdbd164b89949e13617b096 (patch) | |
tree | a8523979b784a4f0a9131fec2cf8ad56cf356f0f /drivers | |
parent | 35b7a1915aa33da812074744647db0d9262a555c (diff) |
net: bcmgenet: fix off-by-one in incrementing read pointer
Commit b629be5c8399d7c423b92135eb43a86c924d1cbc ("net: bcmgenet: check
harder for out of memory conditions") moved the increment of the local
read pointer *before* reading from the hardware descriptor using
dmadesc_get_length_status(), which creates an off-by-one situation.
Fix this by moving again the read_ptr increment after we have read the
hardware descriptor to get both the control block and the read pointer
back in sync.
Fixes: b629be5c8399 ("net: bcmgenet: check harder for out of memory conditions")
Signed-off-by: Jaedon Shin <jaedon.shin@gmail.com>
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Acked-by: Petri Gynther <pgynther@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/ethernet/broadcom/genet/bcmgenet.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c index fff2634b6f34..fdc9ec09e453 100644 --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c | |||
@@ -1285,11 +1285,6 @@ static unsigned int bcmgenet_desc_rx(struct bcmgenet_priv *priv, | |||
1285 | cb = &priv->rx_cbs[priv->rx_read_ptr]; | 1285 | cb = &priv->rx_cbs[priv->rx_read_ptr]; |
1286 | skb = cb->skb; | 1286 | skb = cb->skb; |
1287 | 1287 | ||
1288 | rxpktprocessed++; | ||
1289 | |||
1290 | priv->rx_read_ptr++; | ||
1291 | priv->rx_read_ptr &= (priv->num_rx_bds - 1); | ||
1292 | |||
1293 | /* We do not have a backing SKB, so we do not have a | 1288 | /* We do not have a backing SKB, so we do not have a |
1294 | * corresponding DMA mapping for this incoming packet since | 1289 | * corresponding DMA mapping for this incoming packet since |
1295 | * bcmgenet_rx_refill always either has both skb and mapping or | 1290 | * bcmgenet_rx_refill always either has both skb and mapping or |
@@ -1404,6 +1399,10 @@ refill: | |||
1404 | err = bcmgenet_rx_refill(priv, cb); | 1399 | err = bcmgenet_rx_refill(priv, cb); |
1405 | if (err) | 1400 | if (err) |
1406 | netif_err(priv, rx_err, dev, "Rx refill failed\n"); | 1401 | netif_err(priv, rx_err, dev, "Rx refill failed\n"); |
1402 | |||
1403 | rxpktprocessed++; | ||
1404 | priv->rx_read_ptr++; | ||
1405 | priv->rx_read_ptr &= (priv->num_rx_bds - 1); | ||
1407 | } | 1406 | } |
1408 | 1407 | ||
1409 | return rxpktprocessed; | 1408 | return rxpktprocessed; |