When we come to a new_root, we should go up the tree to get the old root for replacement. Instead of ascend both left/right subtree, we only ascend one of it is enough. Let's use the left subtree as it dose now. Signed-off-by: Wei Yang <richard.weiyang@xxxxxxxxx> CC: Liam R. Howlett <Liam.Howlett@xxxxxxxxxx> CC: Sidhartha Kumar <sidhartha.kumar@xxxxxxxxxx> CC: Lorenzo Stoakes <lorenzo.stoakes@xxxxxxxxxx> --- lib/maple_tree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 4ba9ae68c0a9..2c05919be168 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -2920,7 +2920,7 @@ static void mas_spanning_rebalance(struct ma_state *mas, new_root: mas_mn(mast->l)->parent = ma_parent_ptr(mas_tree_parent(mas)); while (!mte_is_root(mast->orig_l->node)) - mast_ascend(mast); + mas_ascend(mast->orig_l); } else { mas_mn(&l_mas)->parent = mas_mn(mast->orig_l)->parent; } -- 2.34.1