Skip to content

Commit

Permalink
list debugging: warn when deleting a deleted entry
Browse files Browse the repository at this point in the history
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 <[email protected]>
Cc: Dave Jones <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
baruchsiach authored and torvalds committed Aug 10, 2010
1 parent 55817d3 commit e3f76e3
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/list_debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ EXPORT_SYMBOL(__list_add);
*/
void list_del(struct list_head *entry)
{
WARN(entry->next == LIST_POISON1,
"list_del corruption, next is LIST_POISON1 (%p)\n",
LIST_POISON1);
WARN(entry->next != LIST_POISON1 && entry->prev == LIST_POISON2,
"list_del corruption, prev is LIST_POISON2 (%p)\n",
LIST_POISON2);
WARN(entry->prev->next != entry,
"list_del corruption. prev->next should be %p, "
"but was %p\n", entry, entry->prev->next);
Expand Down

0 comments on commit e3f76e3

Please sign in to comment.