]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
maple_tree: mas_max_gap() breaks out of loop on 0 pivot
authorLiam R. Howlett <Liam.Howlett@Oracle.com>
Wed, 23 Sep 2020 02:41:45 +0000 (22:41 -0400)
committerLiam R. Howlett <Liam.Howlett@Oracle.com>
Tue, 5 Jan 2021 17:30:28 +0000 (12:30 -0500)
Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
lib/maple_tree.c

index 9d52bf8fd757ffa5d68815a58df50a82142e01cf..1d89ea6f0c295845f5d6c7485d60dcd8221f31ec 100644 (file)
@@ -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;