Signed-off-by: Wang ShaoBo bobo.shaobowang@huawei.com --- include/linux/list.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
diff --git a/include/linux/list.h b/include/linux/list.h index a18c87b63376..b858dc1ce663 100644 --- a/include/linux/list.h +++ b/include/linux/list.h @@ -7,6 +7,7 @@ #include <linux/poison.h> #include <linux/const.h> #include <linux/kernel.h> +#include <asm/bug.h>
/* * Simple doubly linked list implementation. @@ -71,6 +72,17 @@ static inline void __list_add(struct list_head *new, new->next = next; new->prev = prev; WRITE_ONCE(prev->next, new); + + WARN_ON(next->prev != new); + WARN_ON(new->next != next); + WARN_ON(new->prev != prev); + WARN_ON(prev->next != new); + wmb(); + mb(); + WARN_ON(next->prev != new); + WARN_ON(new->next != next); + WARN_ON(new->prev != prev); + WARN_ON(prev->next != new); }
/** @@ -111,6 +123,13 @@ static inline void __list_del(struct list_head * prev, struct list_head * next) { next->prev = prev; WRITE_ONCE(prev->next, next); + + WARN_ON(next->prev != prev); + WARN_ON(prev->next != next); + wmb(); + mb(); + WARN_ON(next->prev != prev); + WARN_ON(prev->next != next); }
/*