hp100: fix an skb->len race
authorEric Dumazet <eric.dumazet@gmail.com>
Sun, 19 Jun 2011 12:43:33 +0000 (12:43 +0000)
committerDavid S. Miller <davem@davemloft.net>
Sun, 19 Jun 2011 23:28:02 +0000 (16:28 -0700)
As soon as skb is given to hardware and spinlock released, TX completion
can free skb under us. Therefore, we should update netdev stats before
spinlock release.

Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/hp100.c

index 8e10d2f6a5adc8340d239c729e835fb0122b3acd..c3ecb118c1df39f925e40f023f6e2f8a63ec763f 100644 (file)
@@ -1580,12 +1580,12 @@ static netdev_tx_t hp100_start_xmit_bm(struct sk_buff *skb,
        hp100_outl(ringptr->pdl_paddr, TX_PDA_L);       /* Low Prio. Queue */
 
        lp->txrcommit++;
-       spin_unlock_irqrestore(&lp->lock, flags);
 
-       /* Update statistics */
        dev->stats.tx_packets++;
        dev->stats.tx_bytes += skb->len;
 
+       spin_unlock_irqrestore(&lp->lock, flags);
+
        return NETDEV_TX_OK;
 
 drop: