From 79539364d5c733cb56c95e2a763b8c47f1e6f75f Mon Sep 17 00:00:00 2001 From: "Liam R. Howlett" Date: Tue, 14 May 2019 13:49:12 -0400 Subject: [PATCH] maple_tree: Fix range checking on skip_node When skipping a node, it is only valid to break out of the loop if slot + 1 is valid. Signed-off-by: Liam R. Howlett --- lib/maple_tree.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index d75c4c2659eb..077469fc0147 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -1856,15 +1856,13 @@ static inline bool _mas_awalk(struct ma_state *mas, unsigned long size) enum maple_type type; unsigned long pivot, max, min; unsigned char pivot_cnt, i; - bool leaf = false, found = false; + bool found = false; min = mas->min; max = mas->max; type = mt_node_type(mas->node); pivot_cnt = mt_pivots[type]; - if (type < maple_range_16) - leaf = true; switch (type) { case maple_leaf_64: @@ -1950,7 +1948,7 @@ next: } - if (!leaf) { // descend. + if (type >= maple_range_16) { //descend struct maple_enode *next; next = _ma_get_rcu_slot(mas->node, i, type); mas->min = min; @@ -2198,7 +2196,7 @@ static inline bool mas_skip_node(struct ma_state *mas) do { if (ma_is_root(mas->node)) { slot = ma_get_slot(mas); - if (slot >= mt_slot_count(mas->node) - 1) { + if (slot > mt_slot_count(mas->node) - 1) { mas_set_err(mas, -EBUSY); return false; } @@ -2206,7 +2204,7 @@ static inline bool mas_skip_node(struct ma_state *mas) slot = mt_parent_slot(mas->node); ma_encoded_parent(mas); } - } while (slot >= mt_slot_count(mas->node) - 1); + } while (slot > mt_slot_count(mas->node) - 1); ma_set_slot(mas, ++slot); mas_update_limits(mas, slot, mt_node_type(mas->node)); -- 2.50.1