From 533f73d7b8e70ec6b768a1bd00c7c6b9598b37df Mon Sep 17 00:00:00 2001 From: "Liam R. Howlett" Date: Tue, 6 Oct 2020 15:38:38 -0400 Subject: [PATCH] maple_tree: Return NULL on unlikely not found case. Signed-off-by: Liam R. Howlett --- lib/maple_tree.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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, -- 2.50.1