Skip to content

Commit ec07967

Browse files
Peng Zhangakpm00
authored andcommitted
maple_tree: fix get wrong data_end in mtree_lookup_walk()
if (likely(offset > end)) max = pivots[offset]; The above code should be changed to if (likely(offset < end)), which is correct. This affects the correctness of ma_data_end(). Now it seems that the final result will not be wrong, but it is best to change it. This patch does not change the code as above, because it simplifies the code by the way. Link: https://lkml.kernel.org/r/[email protected] Link: https://lkml.kernel.org/r/[email protected] Fixes: 54a611b ("Maple Tree: add new data structure") Signed-off-by: Peng Zhang <[email protected]> Reviewed-by: Liam R. Howlett <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 6fe7d6b commit ec07967

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

lib/maple_tree.c

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3941,18 +3941,13 @@ static inline void *mtree_lookup_walk(struct ma_state *mas)
39413941
end = ma_data_end(node, type, pivots, max);
39423942
if (unlikely(ma_dead_node(node)))
39433943
goto dead_node;
3944-
3945-
if (pivots[offset] >= mas->index)
3946-
goto next;
3947-
39483944
do {
3949-
offset++;
3950-
} while ((offset < end) && (pivots[offset] < mas->index));
3951-
3952-
if (likely(offset > end))
3953-
max = pivots[offset];
3945+
if (pivots[offset] >= mas->index) {
3946+
max = pivots[offset];
3947+
break;
3948+
}
3949+
} while (++offset < end);
39543950

3955-
next:
39563951
slots = ma_slots(node, type);
39573952
next = mt_slot(mas->tree, slots, offset);
39583953
if (unlikely(ma_dead_node(node)))

0 commit comments

Comments
 (0)