Merge tag 'mm-nonmm-stable-2022-05-26' of git://git.kernel.org/pub/scm/linux/kernel...
[linux-2.6-microblaze.git] / include / linux / list.h
index 57e8b55..6176205 100644 (file)
@@ -35,7 +35,7 @@
 static inline void INIT_LIST_HEAD(struct list_head *list)
 {
        WRITE_ONCE(list->next, list);
-       list->prev = list;
+       WRITE_ONCE(list->prev, list);
 }
 
 #ifdef CONFIG_DEBUG_LIST
@@ -306,7 +306,7 @@ static inline int list_empty(const struct list_head *head)
 static inline void list_del_init_careful(struct list_head *entry)
 {
        __list_del_entry(entry);
-       entry->prev = entry;
+       WRITE_ONCE(entry->prev, entry);
        smp_store_release(&entry->next, entry);
 }
 
@@ -326,7 +326,7 @@ static inline void list_del_init_careful(struct list_head *entry)
 static inline int list_empty_careful(const struct list_head *head)
 {
        struct list_head *next = smp_load_acquire(&head->next);
-       return list_is_head(next, head) && (next == head->prev);
+       return list_is_head(next, head) && (next == READ_ONCE(head->prev));
 }
 
 /**