From: Liam R. Howlett Date: Wed, 11 Nov 2020 18:36:14 +0000 (-0500) Subject: maple_tree: reset mas->node to MAS_START in mas_next() if it's MAS_NONE X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=7a301abdae42de65ac1ed7fad61eee614d1d610d;p=users%2Fjedix%2Flinux-maple.git maple_tree: reset mas->node to MAS_START in mas_next() if it's MAS_NONE Signed-off-by: Liam R. Howlett --- diff --git a/lib/maple_tree.c b/lib/maple_tree.c index c2a6c9cfd28c..476c197d7adb 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -793,7 +793,7 @@ static inline void mas_ascend(struct ma_state *mas) a_enode = p_enode; if (mte_is_root(a_enode)) { a_node = mte_to_node(a_enode); - goto no_parent; + goto parent_is_root; } mas->node = p_enode; @@ -812,6 +812,7 @@ ascend: max = mte_pivot(a_enode, a_slot); } +parent_is_root: no_parent: if (ma_is_root(a_node)) { if (!set_min) @@ -4529,6 +4530,9 @@ void *mas_next(struct ma_state *mas, unsigned long max) { unsigned long index = 0; + if (mas_is_none(mas)) + mas->node = MAS_START; + return _mas_next(mas, max, &index); } EXPORT_SYMBOL_GPL(mas_next); @@ -4924,7 +4928,7 @@ void *mas_store(struct ma_state *mas, void *entry) if (mas_is_err(mas)) return existing; - if (!mte_is_leaf(mas->node)) // gaps were updated + if (!mte_is_leaf(mas->node)) // spanning store occurred mas->node = MAS_START; return existing; @@ -4951,7 +4955,7 @@ retry: if (mas_is_err(mas)) return xa_err(mas->node); - if (!mte_is_leaf(mas->node)) // gaps were updated + if (!mte_is_leaf(mas->node)) // spanning store occurred mas->node = MAS_START; return 0;