From 0a16fa0711f185a3e5046f7a94605ffc14ebf703 Mon Sep 17 00:00:00 2001 From: "Liam R. Howlett" Date: Thu, 22 Oct 2020 14:46:13 -0400 Subject: [PATCH] maple_tree: Fix mas_for_each limits on index when searching for first entry in node Signed-off-by: Liam R. Howlett --- lib/maple_tree.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index cd0d4a84015b..f8f94474eced 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -1281,18 +1281,18 @@ static inline void mas_update_gap(struct ma_state *mas) } /* - * mas_first_entry() - * Returns the pivot which points to the entry with the - * lowest index. + * mas_first_entry() - Go the first leaf and find the first entry. * * @mas: the maple state. * @limit: the maximum index to check. + * Returns: The start of the pivot. */ static inline unsigned long mas_first_entry(struct ma_state *mas, unsigned long limit) { void **slots, *entry; int offset = 0; - unsigned long pivot = mas->min; + unsigned long prev_piv = mas->min; while (!mte_is_leaf(mas->node)) { mas->max = mte_pivot(mas->node, 0); @@ -1303,18 +1303,18 @@ static inline unsigned long mas_first_entry(struct ma_state *mas, slots = ma_slots(mte_to_node(mas->node), mte_node_type(mas->node)); - while ((pivot < limit) && (offset < mt_slot_count(mas->node))) { - pivot = mas_safe_pivot(mas, offset); + while ((prev_piv < limit) && (offset < mt_slot_count(mas->node))) { entry = mas_slot(mas, slots, offset); if (entry) { mas_set_offset(mas, offset); - return pivot; + return prev_piv; } + prev_piv = mas_safe_pivot(mas, offset); offset++; } mas->node = MAS_NONE; - return pivot; + return prev_piv; } /* -- 2.50.1