]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
maple_tree: Fix rcu_dereference usages
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Mon, 2 Mar 2020 21:16:00 +0000 (16:16 -0500)
committerLiam R. Howlett <Liam.Howlett@Oracle.com>
Fri, 30 Oct 2020 19:04:30 +0000 (15:04 -0400)
Enabling CONFIG_PROVE_LOCKING reveals some compilation errors and
running it shows that loading the root pointer needs to be done with
rcu_dereference_protected() (which will permit the load if the lock is
held) instead of a plain rcu_dereference() (which permits the load if
the rcu read lock is held).

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
lib/maple_tree.c

index 4d9fa3a5d9a203963c1b6a485455ac283dae1187..637a74e9bb147f892245d869a1a622b345426897 100644 (file)
@@ -2755,7 +2755,8 @@ static inline int _mas_insert(struct ma_state *mas, void *entry,
 
 static inline void mas_root_expand(struct ma_state *mas, void *entry)
 {
-       void *r_entry = rcu_dereference(mas->tree->ma_root);  // root entry
+       void *r_entry = rcu_dereference_protected(mas->tree->ma_root,
+                               lockdep_is_held(&mas->tree->ma_lock));
        struct maple_node *mn;
        enum maple_type mt = mas_ptype_leaf(mas);
        int slot = 0;