]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
maple_tree: Return NULL on unlikely not found case.
authorLiam R. Howlett <Liam.Howlett@Oracle.com>
Tue, 6 Oct 2020 19:38:38 +0000 (15:38 -0400)
committerLiam R. Howlett <Liam.Howlett@Oracle.com>
Fri, 30 Oct 2020 19:12:56 +0000 (15:12 -0400)
Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
lib/maple_tree.c

index 6ccb1f085d15573d1171c23d36fa8759d8388e51..9a20236d346de8276a9d03f7ed1cab7256fae180 100644 (file)
@@ -3716,6 +3716,8 @@ static inline bool _mas_walk(struct ma_state *mas, unsigned long *range_min,
        }
 
        if (mas_is_ptr(mas)) {
+               *range_min = 0;
+               *range_max = 0;
                if (!mas->index)
                        return true;
                mas_set_offset(mas, MAPLE_NODE_SLOTS);
@@ -3747,13 +3749,18 @@ void *mas_walk(struct ma_state *mas)
 {
        unsigned long range_min, range_max;
        unsigned long index = mas->index;
+       unsigned char offset;
 
        _mas_walk(mas, &range_min, &range_max);
 retry:
        if (mas_dead_node(mas, index))
                goto retry;
 
-       return mas_get_slot(mas, mas_offset(mas));
+       offset = mas_offset(mas);
+       if (offset == MAPLE_NODE_SLOTS)
+               return NULL; // Not found.
+
+       return mas_get_slot(mas, offset);
 }
 
 static inline bool mas_search_cont(struct ma_state *mas, unsigned long index,