From 611bd8f86a1ee676dcd5333c7a620f68b6dfc8dc Mon Sep 17 00:00:00 2001 From: "Matthew Wilcox (Oracle)" Date: Mon, 2 Mar 2020 16:16:00 -0500 Subject: [PATCH] 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) --- lib/maple_tree.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 4d9fa3a5d9a2..637a74e9bb14 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; -- 2.50.1