Skip to content

Commit

Permalink
xen-netfront: Avoid deref'ing skbafter it is potentially freed.
Browse files Browse the repository at this point in the history
xennet_tx_bug_gc can free the skb before we use it, so make sure we don't.

Signed-off-by: Keir Fraser <keir@xensource.com>
Signed-off-by: Jeremy Fitzhardinge <jeremy@xensource.com>
Cc: Jeff Garzik <jeff@garzik.org>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
  • Loading branch information
Jeremy Fitzhardinge authored and Jeff Garzik committed Aug 14, 2007
1 parent a6d8991 commit 10a273a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions drivers/net/xen-netfront.c
Original file line number Diff line number Diff line change
Expand Up @@ -566,16 +566,17 @@ static int xennet_start_xmit(struct sk_buff *skb, struct net_device *dev)
if (notify)
notify_remote_via_irq(np->netdev->irq);

np->stats.tx_bytes += skb->len;
np->stats.tx_packets++;

/* Note: It is not safe to access skb after xennet_tx_buf_gc()! */
xennet_tx_buf_gc(dev);

if (!netfront_tx_slot_available(np))
netif_stop_queue(dev);

spin_unlock_irq(&np->tx_lock);

np->stats.tx_bytes += skb->len;
np->stats.tx_packets++;

return 0;

drop:
Expand Down

0 comments on commit 10a273a

Please sign in to comment.