]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
maple_tree: Add smp_rmb() to dead node detection
authorLiam R. Howlett <Liam.Howlett@oracle.com>
Wed, 4 Jan 2023 02:37:29 +0000 (21:37 -0500)
committerLiam R. Howlett <Liam.Howlett@oracle.com>
Wed, 4 Jan 2023 20:57:53 +0000 (15:57 -0500)
Add an smp_rmb() before reading the parent pointer to ensure that
anything read from the node prior to the parent pointer hasn't been
reordered ahead of this check.

The is necessary for RCU mode.

Fixes: 54a611b60590 ("Maple Tree: add new data structure")
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
lib/maple_tree.c

index 17a4fc3b1cc0af8348100fdd92233512ac23df77..27d153dcbe343481060fe183a7f35b3353cde850 100644 (file)
@@ -530,9 +530,10 @@ static inline struct maple_node *mte_parent(const struct maple_enode *enode)
  */
 static inline bool ma_dead_node(const struct maple_node *node)
 {
-       struct maple_node *parent = (void *)((unsigned long)
-                                            node->parent & ~MAPLE_NODE_MASK);
+       struct maple_node *parent;
 
+       smp_rmb();
+       parent = (void *)((unsigned long) node->parent & ~MAPLE_NODE_MASK);
        return (parent == node);
 }
 
@@ -547,6 +548,7 @@ static inline bool mte_dead_node(const struct maple_enode *enode)
        struct maple_node *parent, *node;
 
        node = mte_to_node(enode);
+       smp_rmb();
        parent = mte_parent(enode);
        return (parent == node);
 }