From: Wei Yang <richard.weiyang@gmail.com>
To: Liam.Howlett@oracle.com, akpm@linux-foundation.org, willy@infradead.org
Cc: maple-tree@lists.infradead.org, linux-mm@kvack.org,
Wei Yang <richard.weiyang@gmail.com>,
"Liam R . Howlett" <Liam.Howlett@Oracle.com>,
stable@vger.kernel.org
Subject: [Patch v3 1/3] maple_tree: Fix mt_destroy_walk() on root leaf node
Date: Wed, 11 Jun 2025 01:12:51 +0000 [thread overview]
Message-ID: <20250611011253.19515-2-richard.weiyang@gmail.com> (raw)
In-Reply-To: <20250611011253.19515-1-richard.weiyang@gmail.com>
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.
Fixes this by setting the node dead if it is a leaf.
Fixes: 54a611b60590 ("Maple Tree: add new data structure")
Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
Cc: Liam R. Howlett <Liam.Howlett@Oracle.com>
Cc: <stable@vger.kernel.org>
Reviewed-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
---
v2:
* move the operation into mt_destroy_walk()
* adjust the title accordingly
---
lib/maple_tree.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/lib/maple_tree.c b/lib/maple_tree.c
index affe979bd14d..b0c345b6e646 100644
--- a/lib/maple_tree.c
+++ b/lib/maple_tree.c
@@ -5319,6 +5319,7 @@ static void mt_destroy_walk(struct maple_enode *enode, struct maple_tree *mt,
struct maple_enode *start;
if (mte_is_leaf(enode)) {
+ mte_set_node_dead(enode);
node->type = mte_node_type(enode);
goto free_leaf;
}
--
2.34.1
next prev parent reply other threads:[~2025-06-11 1:13 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-11 1:12 [Patch v3 0/3] maple_tree: Fix the replacement of a root leaf node Wei Yang
2025-06-11 1:12 ` Wei Yang [this message]
2025-06-11 1:12 ` [Patch v3 2/3] maple_tree: restart walk on correct status Wei Yang
2025-06-11 1:12 ` [Patch v3 3/3] maple_tree: assert retrieving new value on a tree containing just a leaf node Wei Yang
2025-06-11 1:37 ` [Patch v3 0/3] maple_tree: Fix the replacement of a root " Andrew Morton
2025-06-11 2:54 ` Wei Yang
2025-06-11 3:55 ` Andrew Morton
2025-06-11 6:15 ` Wei Yang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250611011253.19515-2-richard.weiyang@gmail.com \
--to=richard.weiyang@gmail.com \
--cc=Liam.Howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=linux-mm@kvack.org \
--cc=maple-tree@lists.infradead.org \
--cc=stable@vger.kernel.org \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).