aboutsummaryrefslogtreecommitdiff
path: root/net/atm/ipcommon.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@g5.osdl.org>2006-07-09 15:50:41 -0700
committerLinus Torvalds <torvalds@g5.osdl.org>2006-07-09 15:50:41 -0700
commit09075ef0fd585fb093bb9a6cd1240272114f89cf (patch)
treec01d2cc260a18df73f785bea4de1c1cfbcbbd16f /net/atm/ipcommon.c
parentc87fed1546bd00b42ee75f26c6b45393e4bf7559 (diff)
parent1b30dd359ebec22d035e8b145751319f63772ca1 (diff)
Merge commit master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6 of HEAD
* HEAD: [AX.25]: Use kzalloc [ATM] net/atm/clip.c: fix PROC_FS=n compile [PKT_SCHED]: act_api: Fix module leak while flushing actions [NET]: Fix IPv4/DECnet routing rule dumping [NET] gso: Fix up GSO packets with broken checksums [NET] gso: Add skb_is_gso [IRDA]: fix drivers/net/irda/ali-ircc.c:ali_ircc_init() [ATM]: fix possible recursive locking in skb_migrate() [ATM]: Typo in drivers/atm/Kconfig... [TG3]: add amd8131 to "write reorder" chipsets [NET]: Fix network device interface printk message priority
Diffstat (limited to 'net/atm/ipcommon.c')
-rw-r--r--net/atm/ipcommon.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/net/atm/ipcommon.c b/net/atm/ipcommon.c
index 4b1faca5013..1d3de42fada 100644
--- a/net/atm/ipcommon.c
+++ b/net/atm/ipcommon.c
@@ -25,22 +25,27 @@
/*
* skb_migrate appends the list at "from" to "to", emptying "from" in the
* process. skb_migrate is atomic with respect to all other skb operations on
- * "from" and "to". Note that it locks both lists at the same time, so beware
- * of potential deadlocks.
+ * "from" and "to". Note that it locks both lists at the same time, so to deal
+ * with the lock ordering, the locks are taken in address order.
*
* This function should live in skbuff.c or skbuff.h.
*/
-void skb_migrate(struct sk_buff_head *from,struct sk_buff_head *to)
+void skb_migrate(struct sk_buff_head *from, struct sk_buff_head *to)
{
unsigned long flags;
struct sk_buff *skb_from = (struct sk_buff *) from;
struct sk_buff *skb_to = (struct sk_buff *) to;
struct sk_buff *prev;
- spin_lock_irqsave(&from->lock,flags);
- spin_lock(&to->lock);
+ if ((unsigned long) from < (unsigned long) to) {
+ spin_lock_irqsave(&from->lock, flags);
+ spin_lock_nested(&to->lock, SINGLE_DEPTH_NESTING);
+ } else {
+ spin_lock_irqsave(&to->lock, flags);
+ spin_lock_nested(&from->lock, SINGLE_DEPTH_NESTING);
+ }
prev = from->prev;
from->next->prev = to->prev;
prev->next = skb_to;
@@ -51,7 +56,7 @@ void skb_migrate(struct sk_buff_head *from,struct sk_buff_head *to)
from->prev = skb_from;
from->next = skb_from;
from->qlen = 0;
- spin_unlock_irqrestore(&from->lock,flags);
+ spin_unlock_irqrestore(&from->lock, flags);
}