]> git.hungrycats.org Git - linux/commitdiff
[PATCH] list_head debugging
authorAndrew Morton <akpm@zip.com.au>
Sun, 2 Jun 2002 10:21:53 +0000 (03:21 -0700)
committerLinus Torvalds <torvalds@home.transmeta.com>
Sun, 2 Jun 2002 10:21:53 +0000 (03:21 -0700)
A common and very subtle bug is to use list_heads which aren't on any
lists.  It causes kernel memory corruption which is observed long after
the offending code has executed.

The patch nulls out the dangling pointers so we get a nice oops at the
site of the buggy code.

include/linux/list.h

index 99da4ab62ec24b5331d98a59b7c2a43800270d45..6331739453a045525bfed8b7c3b779e71dab800b 100644 (file)
@@ -94,6 +94,8 @@ static __inline__ void __list_del(struct list_head * prev,
 static __inline__ void list_del(struct list_head *entry)
 {
        __list_del(entry->prev, entry->next);
+       entry->next = NULL;
+       entry->prev = NULL;
 }
 
 /**