From: Liam R. Howlett Date: Tue, 6 Oct 2020 19:38:38 +0000 (-0400) Subject: maple_tree: Return NULL on unlikely not found case. X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=6439ac6fa75d9db8740b8250b5e3f9ec1e4ae4fe;p=users%2Fjedix%2Flinux-maple.git maple_tree: Return NULL on unlikely not found case. Signed-off-by: Liam R. Howlett --- diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 6ccb1f085d15..9a20236d346d 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -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,