Skip to content

Commit

Permalink
list: Use WRITE_ONCE() when initializing list_head structures
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Paul E. McKenney committed Dec 4, 2015
1 parent 7d86dcc commit 2f07384
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion include/linux/list.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 2f07384

Please sign in to comment.