mv643xx_eth: fix race in trasmit path.
authorRichard Cochran <richard.cochran@omicron.at>
Tue, 21 Jun 2011 23:00:24 +0000 (16:00 -0700)
committerDavid S. Miller <davem@davemloft.net>
Tue, 21 Jun 2011 23:00:24 +0000 (16:00 -0700)
Because the socket buffer is freed in the completion interrupt, it is not
safe to access it after submitting it to the hardware.

Signed-off-by: Richard Cochran <richard.cochran@omicron.at>
Acked-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/mv643xx_eth.c

index a5d9b1c..1b7d2c1 100644 (file)
@@ -859,7 +859,7 @@ no_csum:
 static netdev_tx_t mv643xx_eth_xmit(struct sk_buff *skb, struct net_device *dev)
 {
        struct mv643xx_eth_private *mp = netdev_priv(dev);
-       int queue;
+       int length, queue;
        struct tx_queue *txq;
        struct netdev_queue *nq;
 
@@ -881,10 +881,12 @@ static netdev_tx_t mv643xx_eth_xmit(struct sk_buff *skb, struct net_device *dev)
                return NETDEV_TX_OK;
        }
 
+       length = skb->len;
+
        if (!txq_submit_skb(txq, skb)) {
                int entries_left;
 
-               txq->tx_bytes += skb->len;
+               txq->tx_bytes += length;
                txq->tx_packets++;
 
                entries_left = txq->tx_ring_size - txq->tx_desc_count;