From: Liam R. Howlett Date: Wed, 23 Sep 2020 02:41:45 +0000 (-0400) Subject: maple_tree: mas_max_gap() breaks out of loop on 0 pivot X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=2894b04c24677c082018b71487f4f9502c06f8e5;p=users%2Fjedix%2Flinux-maple.git maple_tree: mas_max_gap() breaks out of loop on 0 pivot Signed-off-by: Liam R. Howlett --- 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;