From: Matthew Wilcox (Oracle) Date: Mon, 2 Mar 2020 21:16:00 +0000 (-0500) Subject: maple_tree: Fix rcu_dereference usages X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=611bd8f86a1ee676dcd5333c7a620f68b6dfc8dc;p=users%2Fjedix%2Flinux-maple.git maple_tree: Fix rcu_dereference usages 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) --- diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 4d9fa3a5d9a20..637a74e9bb147 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -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;