diff options
author | Eric Dumazet <eric.dumazet@gmail.com> | 2012-03-14 05:21:44 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-03-16 05:01:41 -0400 |
commit | b8fbaef586176f6abe0eb7887ddae66e99898b79 (patch) | |
tree | de0789276c35e3cb5d55dc858ce6b76a30918efc /drivers | |
parent | bb6d5e76fb4fba9aa36726db41404512f3286c0f (diff) |
wimax/i2400m: fix erroneous NETDEV_TX_BUSY use
A driver start_xmit() method cannot free skb and return NETDEV_TX_BUSY,
since caller is going to reuse freed skb.
In fact netif_tx_stop_queue() / netif_stop_queue() is needed before
returning NETDEV_TX_BUSY or you can trigger a ksoftirqd fatal loop.
In case of memory allocation error, only safe way is to drop the packet
and return NETDEV_TX_OK
Also increments tx_dropped counter
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/wimax/i2400m/netdev.c | 30 |
1 files changed, 10 insertions, 20 deletions
diff --git a/drivers/net/wimax/i2400m/netdev.c b/drivers/net/wimax/i2400m/netdev.c index 64a110604ad3..63e4b709efa9 100644 --- a/drivers/net/wimax/i2400m/netdev.c +++ b/drivers/net/wimax/i2400m/netdev.c | |||
@@ -367,38 +367,28 @@ netdev_tx_t i2400m_hard_start_xmit(struct sk_buff *skb, | |||
367 | { | 367 | { |
368 | struct i2400m *i2400m = net_dev_to_i2400m(net_dev); | 368 | struct i2400m *i2400m = net_dev_to_i2400m(net_dev); |
369 | struct device *dev = i2400m_dev(i2400m); | 369 | struct device *dev = i2400m_dev(i2400m); |
370 | int result; | 370 | int result = -1; |
371 | 371 | ||
372 | d_fnstart(3, dev, "(skb %p net_dev %p)\n", skb, net_dev); | 372 | d_fnstart(3, dev, "(skb %p net_dev %p)\n", skb, net_dev); |
373 | if (skb_header_cloned(skb)) { | 373 | |
374 | /* | 374 | if (skb_header_cloned(skb) && |
375 | * Make tcpdump/wireshark happy -- if they are | 375 | pskb_expand_head(skb, 0, 0, GFP_ATOMIC)) |
376 | * running, the skb is cloned and we will overwrite | 376 | goto drop; |
377 | * the mac fields in i2400m_tx_prep_header. Expand | ||
378 | * seems to fix this... | ||
379 | */ | ||
380 | result = pskb_expand_head(skb, 0, 0, GFP_ATOMIC); | ||
381 | if (result) { | ||
382 | result = NETDEV_TX_BUSY; | ||
383 | goto error_expand; | ||
384 | } | ||
385 | } | ||
386 | 377 | ||
387 | if (i2400m->state == I2400M_SS_IDLE) | 378 | if (i2400m->state == I2400M_SS_IDLE) |
388 | result = i2400m_net_wake_tx(i2400m, net_dev, skb); | 379 | result = i2400m_net_wake_tx(i2400m, net_dev, skb); |
389 | else | 380 | else |
390 | result = i2400m_net_tx(i2400m, net_dev, skb); | 381 | result = i2400m_net_tx(i2400m, net_dev, skb); |
391 | if (result < 0) | 382 | if (result < 0) { |
383 | drop: | ||
392 | net_dev->stats.tx_dropped++; | 384 | net_dev->stats.tx_dropped++; |
393 | else { | 385 | } else { |
394 | net_dev->stats.tx_packets++; | 386 | net_dev->stats.tx_packets++; |
395 | net_dev->stats.tx_bytes += skb->len; | 387 | net_dev->stats.tx_bytes += skb->len; |
396 | } | 388 | } |
397 | result = NETDEV_TX_OK; | 389 | dev_kfree_skb(skb); |
398 | error_expand: | ||
399 | kfree_skb(skb); | ||
400 | d_fnend(3, dev, "(skb %p net_dev %p) = %d\n", skb, net_dev, result); | 390 | d_fnend(3, dev, "(skb %p net_dev %p) = %d\n", skb, net_dev, result); |
401 | return result; | 391 | return NETDEV_TX_OK; |
402 | } | 392 | } |
403 | 393 | ||
404 | 394 | ||