From: Chris Metcalf Date: Tue, 29 May 2012 22:07:31 +0000 (-0700) Subject: list_debug: WARN for adding something already in the list X-Git-Tag: v3.5-rc1~49^2~20 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=17a801f4bfeb;p=karo-tx-linux.git list_debug: WARN for adding something already in the list We were bitten by this at one point and added an additional sanity test for DEBUG_LIST. You can't validly add a list_head to a list where either prev or next is the same as the thing you're adding. Signed-off-by: Chris Metcalf Cc: Andi Kleen Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/lib/list_debug.c b/lib/list_debug.c index 3810b481f940..23a5e031cd8b 100644 --- a/lib/list_debug.c +++ b/lib/list_debug.c @@ -31,6 +31,9 @@ void __list_add(struct list_head *new, "list_add corruption. prev->next should be " "next (%p), but was %p. (prev=%p).\n", next, prev->next, prev); + WARN(new == prev || new == next, + "list_add double add: new=%p, prev=%p, next=%p.\n", + new, prev, next); next->prev = new; new->next = next; new->prev = prev;