From: Liam R. Howlett Date: Wed, 30 Nov 2022 16:33:54 +0000 (-0500) Subject: maple_tree: Avoid crashing on mte_set_pivot() out of range X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=5dfc819cee0c8a021828d68c897d68bde23e51fe;p=users%2Fjedix%2Flinux-maple.git maple_tree: Avoid crashing on mte_set_pivot() out of range 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 --- diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 7466a6f0a2ab..766f257a98a4 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -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: