Skip to content

Commit 0a2b18d

Browse files
howlettakpm00
authored andcommitted
maple_tree: add smp_rmb() to dead node detection
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. Link: https://lkml.kernel.org/r/[email protected] Fixes: 54a611b ("Maple Tree: add new data structure") Signed-off-by: Liam R. Howlett <[email protected]> Signed-off-by: Suren Baghdasaryan <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent c13af03 commit 0a2b18d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/maple_tree.c

+6-2
Original file line numberDiff line numberDiff line change
@@ -539,9 +539,11 @@ static inline struct maple_node *mte_parent(const struct maple_enode *enode)
539539
*/
540540
static inline bool ma_dead_node(const struct maple_node *node)
541541
{
542-
struct maple_node *parent = (void *)((unsigned long)
543-
node->parent & ~MAPLE_NODE_MASK);
542+
struct maple_node *parent;
544543

544+
/* Do not reorder reads from the node prior to the parent check */
545+
smp_rmb();
546+
parent = (void *)((unsigned long) node->parent & ~MAPLE_NODE_MASK);
545547
return (parent == node);
546548
}
547549

@@ -556,6 +558,8 @@ static inline bool mte_dead_node(const struct maple_enode *enode)
556558
struct maple_node *parent, *node;
557559

558560
node = mte_to_node(enode);
561+
/* Do not reorder reads from the node prior to the parent check */
562+
smp_rmb();
559563
parent = mte_parent(enode);
560564
return (parent == node);
561565
}

0 commit comments

Comments
 (0)