]> git.karo-electronics.de Git - linux-beck.git/commitdiff
list: Use WRITE_ONCE() when initializing list_head structures
authorPaul E. McKenney <paulmck@linux.vnet.ibm.com>
Mon, 12 Oct 2015 23:56:42 +0000 (16:56 -0700)
committerPaul E. McKenney <paulmck@linux.vnet.ibm.com>
Fri, 4 Dec 2015 20:34:33 +0000 (12:34 -0800)
Code that does lockless emptiness testing of non-RCU lists is relying
on INIT_LIST_HEAD() to write the list head's ->next pointer atomically,
particularly when INIT_LIST_HEAD() is invoked from list_del_init().
This commit therefore adds WRITE_ONCE() to this function's pointer stores
that could affect the head's ->next pointer.

Reported-by: Andrey Konovalov <andreyknvl@google.com>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
include/linux/list.h

index 06c2d887a918867a64757e65e913e9a862385b61..5356f4d661a721ba0446b1183e2a834f3bf3b56f 100644 (file)
@@ -24,7 +24,7 @@
 
 static inline void INIT_LIST_HEAD(struct list_head *list)
 {
-       list->next = list;
+       WRITE_ONCE(list->next, list);
        list->prev = list;
 }