Skip to content

Commit 0db3dc7

Browse files
Stephen Hemmingerdavem330
authored andcommitted
[NETPOLL]: tx lock deadlock fix
If sky2 device poll routine is called from netpoll_send_skb, it would deadlock. The netpoll_send_skb held the netif_tx_lock, and the poll routine could acquire it to clean up skb's. Other drivers might use same locking model. The driver is correct, netpoll should not introduce more locking problems than it causes already. So change the code to drop lock before calling poll handler. Signed-off-by: Stephen Hemminger <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 48d8d7e commit 0db3dc7

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

net/core/netpoll.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -250,22 +250,23 @@ static void netpoll_send_skb(struct netpoll *np, struct sk_buff *skb)
250250
unsigned long flags;
251251

252252
local_irq_save(flags);
253-
if (netif_tx_trylock(dev)) {
254-
/* try until next clock tick */
255-
for (tries = jiffies_to_usecs(1)/USEC_PER_POLL;
256-
tries > 0; --tries) {
253+
/* try until next clock tick */
254+
for (tries = jiffies_to_usecs(1)/USEC_PER_POLL;
255+
tries > 0; --tries) {
256+
if (netif_tx_trylock(dev)) {
257257
if (!netif_queue_stopped(dev))
258258
status = dev->hard_start_xmit(skb, dev);
259+
netif_tx_unlock(dev);
259260

260261
if (status == NETDEV_TX_OK)
261262
break;
262263

263-
/* tickle device maybe there is some cleanup */
264-
netpoll_poll(np);
265-
266-
udelay(USEC_PER_POLL);
267264
}
268-
netif_tx_unlock(dev);
265+
266+
/* tickle device maybe there is some cleanup */
267+
netpoll_poll(np);
268+
269+
udelay(USEC_PER_POLL);
269270
}
270271
local_irq_restore(flags);
271272
}

0 commit comments

Comments
 (0)