Commit e3f76e3386ee38e3654e81c2f3933ccca1f2d639

Authored by Baruch Siach
Committed by Linus Torvalds
1 parent 55817d3d5c

list debugging: warn when deleting a deleted entry

Use the magic LIST_POISON* values to detect an incorrect use of list_del
on a deleted entry.  This DEBUG_LIST specific warning is easier to
understand than the generic Oops message caused by LIST_POISON
dereference.

Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Cc: Dave Jones <davej@codemonkey.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Showing 1 changed file with 6 additions and 0 deletions Side-by-side Diff

... ... @@ -43,6 +43,12 @@
43 43 */
44 44 void list_del(struct list_head *entry)
45 45 {
  46 + WARN(entry->next == LIST_POISON1,
  47 + "list_del corruption, next is LIST_POISON1 (%p)\n",
  48 + LIST_POISON1);
  49 + WARN(entry->next != LIST_POISON1 && entry->prev == LIST_POISON2,
  50 + "list_del corruption, prev is LIST_POISON2 (%p)\n",
  51 + LIST_POISON2);
46 52 WARN(entry->prev->next != entry,
47 53 "list_del corruption. prev->next should be %p, "
48 54 "but was %p\n", entry, entry->prev->next);