From 2894b04c24677c082018b71487f4f9502c06f8e5 Mon Sep 17 00:00:00 2001 From: "Liam R. Howlett" Date: Tue, 22 Sep 2020 22:41:45 -0400 Subject: [PATCH] maple_tree: mas_max_gap() breaks out of loop on 0 pivot Signed-off-by: Liam R. Howlett --- lib/maple_tree.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 9d52bf8fd757..1d89ea6f0c29 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -1106,6 +1106,7 @@ static inline unsigned long mas_max_gap(struct ma_state *mas) { enum maple_type mt = mte_node_type(mas->node); unsigned long *gaps = ma_gaps(mas_mn(mas), mt); + unsigned long *pivots = ma_pivots(mas_mn(mas), mt); unsigned long max_gap = 0; unsigned char i; @@ -1115,6 +1116,9 @@ static inline unsigned long mas_max_gap(struct ma_state *mas) gap = gaps[i]; if (gap > max_gap) max_gap = gap; + + if (i < mt_pivots[mt] && !pivots[i]) + break; } return max_gap; -- 2.50.1