]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
maple_tree: Avoid crashing on mte_set_pivot() out of range
authorLiam R. Howlett <Liam.Howlett@oracle.com>
Wed, 30 Nov 2022 16:33:54 +0000 (11:33 -0500)
committerLiam R. Howlett <Liam.Howlett@oracle.com>
Tue, 13 Dec 2022 21:22:37 +0000 (16:22 -0500)
Emit a warning and return.  The tree will be in an undefined state, but
the warning is more likely to be recorded.

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
lib/maple_tree.c

index 7466a6f0a2ab66f72c745f0175d64e11141a843b..766f257a98a447ab4ea69310080c5a073e674199 100644 (file)
@@ -762,7 +762,9 @@ static inline void mte_set_pivot(struct maple_enode *mn, unsigned char piv,
        struct maple_node *node = mte_to_node(mn);
        enum maple_type type = mte_node_type(mn);
 
-       BUG_ON(piv >= mt_pivots[type]);
+       if (WARN_ON_ONCE(piv >= mt_pivots[type]))
+               return;
+
        switch (type) {
        default:
        case maple_range_64: