[patch 2/16] list_head debugging

Andrew Morton
2002-06-01T08:36:42Z

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.

=====================================

--- 2.5.19/include/linux/list.h~list-debug Sat Jun 1 01:18:05 2002
+++ 2.5.19-akpm/include/linux/list.h Sat Jun 1 01:18:05 2002
@@ -94,6 +94,11 @@ static __inline__ void __list_del(struct
static __inline__ void list_del(struct list_head *entry)
{
__list_del(entry->prev, entry->next);
+ /*
+ * This is debug. Remove it when the kernel has no bugs ;)
+ */
+ entry->next = 0;
+ entry->prev = 0;
}

/**

-