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
rtl8169_tx_interrupt(struct net_device *dev, struct rtl8169_private *tp,
void *ioaddr)
{
unsigned long dirty_tx, tx_left = 0;
int entry = tp->cur_tx % NUM_TX_DESC;
unsigned long dirty_tx, tx_left;
assert(dev != NULL);
assert(tp != NULL);
......@@ -1352,20 +1351,21 @@ rtl8169_tx_interrupt(struct net_device *dev, struct rtl8169_private *tp,
tx_left = tp->cur_tx - dirty_tx;
while (tx_left > 0) {
int entry = dirty_tx % NUM_TX_DESC;
if (!(le32_to_cpu(tp->TxDescArray[entry].status) & OWNbit)) {
int cur = dirty_tx % NUM_TX_DESC;
struct sk_buff *skb = tp->Tx_skbuff[cur];
struct sk_buff *skb = tp->Tx_skbuff[entry];
/* FIXME: is it really accurate for TxErr ? */
tp->stats.tx_bytes += skb->len >= ETH_ZLEN ?
skb->len : ETH_ZLEN;
tp->stats.tx_packets++;
rtl8169_unmap_tx_skb(tp->pci_dev, tp->Tx_skbuff + cur,
tp->TxDescArray + cur);
rtl8169_unmap_tx_skb(tp->pci_dev, tp->Tx_skbuff + entry,
tp->TxDescArray + entry);
dev_kfree_skb_irq(skb);
tp->Tx_skbuff[entry] = NULL;
dirty_tx++;
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