aboutsummaryrefslogtreecommitdiffstats
path: root/lib/list_debug.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/list_debug.c')
-rw-r--r--lib/list_debug.c33
1 files changed, 24 insertions, 9 deletions
diff --git a/lib/list_debug.c b/lib/list_debug.c
index b8029a5..50cac9e 100644
--- a/lib/list_debug.c
+++ b/lib/list_debug.c
@@ -9,6 +9,12 @@
#include <linux/module.h>
#include <linux/list.h>
+#ifdef CONFIG_SEC_DEBUG_LIST_CORRUPTION
+static int list_debug = 0x00000100UL;
+#else
+static int list_debug;
+#endif
+
/*
* Insert a new entry between two known consecutive entries.
*
@@ -20,14 +26,20 @@ void __list_add(struct list_head *new,
struct list_head *prev,
struct list_head *next)
{
- WARN(next->prev != prev,
- "list_add corruption. next->prev should be "
- "prev (%p), but was %p. (next=%p).\n",
- prev, next->prev, next);
- WARN(prev->next != next,
- "list_add corruption. prev->next should be "
- "next (%p), but was %p. (prev=%p).\n",
- next, prev->next, prev);
+ if (list_debug)
+ BUG_ON(next->prev != prev);
+ else
+ WARN(next->prev != prev,
+ "list_add corruption. next->prev should be "
+ "prev (%p), but was %p. (next=%p).\n",
+ prev, next->prev, next);
+ if (list_debug)
+ BUG_ON(prev->next != next);
+ else
+ WARN(prev->next != next,
+ "list_add corruption. prev->next should be "
+ "next (%p), but was %p. (prev=%p).\n",
+ next, prev->next, prev);
next->prev = new;
new->next = next;
new->prev = prev;
@@ -53,8 +65,11 @@ void __list_del_entry(struct list_head *entry)
"but was %p\n", entry, prev->next) ||
WARN(next->prev != entry,
"list_del corruption. next->prev should be %p, "
- "but was %p\n", entry, next->prev))
+ "but was %p\n", entry, next->prev)) {
+ if (list_debug)
+ BUG();
return;
+ }
__list_del(prev, next);
}