[PATCH 1/3] maple_tree: may miss to set node dead on destroy

Wei Yang richard.weiyang at gmail.com
Fri Feb 7 17:18:50 PST 2025


On destroy, we should set each node dead. But current code miss this
when the maple tree has only the root node.

The reason is mt_destroy_walk() leverage mte_destroy_descend() to set
node dead, but this is skipped since the only root node is a leaf.

This patch fixes this by setting the root dead before mt_destroy_walk().

Fixes: 54a611b60590 ("Maple Tree: add new data structure")
Signed-off-by: Wei Yang <richard.weiyang at gmail.com>
CC: Liam R. Howlett <Liam.Howlett at Oracle.com>
Cc: <stable at vger.kernel.org>
---
 lib/maple_tree.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/maple_tree.c b/lib/maple_tree.c
index 198c14dd3377..d31f0a2858f7 100644
--- a/lib/maple_tree.c
+++ b/lib/maple_tree.c
@@ -5347,6 +5347,8 @@ static inline void mte_destroy_walk(struct maple_enode *enode,
 {
 	struct maple_node *node = mte_to_node(enode);
 
+	mte_set_node_dead(enode);
+
 	if (mt_in_rcu(mt)) {
 		mt_destroy_walk(enode, mt, false);
 		call_rcu(&node->rcu, mt_free_walk);
-- 
2.34.1




More information about the maple-tree mailing list