From: Liam R. Howlett Date: Tue, 14 May 2019 17:49:12 +0000 (-0400) Subject: maple_tree: Fix range checking on skip_node X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=79539364d5c733cb56c95e2a763b8c47f1e6f75f;p=users%2Fjedix%2Flinux-maple.git 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 --- 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));