From 5dfc819cee0c8a021828d68c897d68bde23e51fe Mon Sep 17 00:00:00 2001 From: "Liam R. Howlett" Date: Wed, 30 Nov 2022 11:33:54 -0500 Subject: [PATCH] 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 --- lib/maple_tree.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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: -- 2.49.0