Commit 0c998ab4 authored by François Romieu's avatar François Romieu Committed by Jeff Garzik

[netdrvr r8169] fix TX race

- possible tx descriptor index overflow (assume tp->dirty_tx = NUM_TX_DESC/2,
  tp->cur_tx = NUM_TX_DESC - 1 and watch TxDescArray for example);
- the status of an inadequate descriptor is checked.

NB: the bug will not necessarily noticed when tx_left == 1.
parent 84cdd306
...@@ -1341,8 +1341,7 @@ static void ...@@ -1341,8 +1341,7 @@ static void
rtl8169_tx_interrupt(struct net_device *dev, struct rtl8169_private *tp, rtl8169_tx_interrupt(struct net_device *dev, struct rtl8169_private *tp,
void *ioaddr) void *ioaddr)
{ {
unsigned long dirty_tx, tx_left = 0; unsigned long dirty_tx, tx_left;
int entry = tp->cur_tx % NUM_TX_DESC;
assert(dev != NULL); assert(dev != NULL);
assert(tp != NULL); assert(tp != NULL);
...@@ -1352,20 +1351,21 @@ rtl8169_tx_interrupt(struct net_device *dev, struct rtl8169_private *tp, ...@@ -1352,20 +1351,21 @@ rtl8169_tx_interrupt(struct net_device *dev, struct rtl8169_private *tp,
tx_left = tp->cur_tx - dirty_tx; tx_left = tp->cur_tx - dirty_tx;
while (tx_left > 0) { while (tx_left > 0) {
int entry = dirty_tx % NUM_TX_DESC;
if (!(le32_to_cpu(tp->TxDescArray[entry].status) & OWNbit)) { if (!(le32_to_cpu(tp->TxDescArray[entry].status) & OWNbit)) {
int cur = dirty_tx % NUM_TX_DESC; struct sk_buff *skb = tp->Tx_skbuff[entry];
struct sk_buff *skb = tp->Tx_skbuff[cur];
/* FIXME: is it really accurate for TxErr ? */ /* FIXME: is it really accurate for TxErr ? */
tp->stats.tx_bytes += skb->len >= ETH_ZLEN ? tp->stats.tx_bytes += skb->len >= ETH_ZLEN ?
skb->len : ETH_ZLEN; skb->len : ETH_ZLEN;
tp->stats.tx_packets++; tp->stats.tx_packets++;
rtl8169_unmap_tx_skb(tp->pci_dev, tp->Tx_skbuff + cur, rtl8169_unmap_tx_skb(tp->pci_dev, tp->Tx_skbuff + entry,
tp->TxDescArray + cur); tp->TxDescArray + entry);
dev_kfree_skb_irq(skb); dev_kfree_skb_irq(skb);
tp->Tx_skbuff[entry] = NULL;
dirty_tx++; dirty_tx++;
tx_left--; tx_left--;
entry++;
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment