]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
maple_tree: Fix range checking on skip_node
authorLiam R. Howlett <Liam.Howlett@Oracle.com>
Tue, 14 May 2019 17:49:12 +0000 (13:49 -0400)
committerLiam R. Howlett <Liam.Howlett@Oracle.com>
Wed, 31 Jul 2019 14:52:43 +0000 (10:52 -0400)
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 <Liam.Howlett@Oracle.com>
lib/maple_tree.c

index d75c4c2659eb7681b43bec3636159f2d83566fa7..077469fc0147f7ca6b6eb92b086ce1d88411b6d6 100644 (file)
@@ -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));