From: Liam R. Howlett Date: Sun, 31 Aug 2025 00:44:23 +0000 (-0400) Subject: mt_validate() detect root of size 0 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=75a8b16a20c74a95d03223cfa0f8d04fa498aa9b;p=users%2Fjedix%2Flinux-maple.git mt_validate() detect root of size 0 Signed-off-by: Liam R. Howlett --- diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 75cec454d050..a59e95bb6d9e 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -8262,8 +8262,10 @@ void mt_validate(struct maple_tree *mt) while (!mas_is_overflow(&mas)) { MAS_WARN_ON(&mas, mte_dead_node(mas.node)); end = mas_data_end(&mas); - if (MAS_WARN_ON(&mas, (end < mt_min_slot_count(mas.node)) && - (!mte_is_root(mas.node)))) { + if (MAS_WARN_ON(&mas, + ((end < mt_min_slot_count(mas.node)) && + (!mte_is_root(mas.node))) || + (mte_is_root(mas.node) && end < 1))) { pr_err("Invalid size %u of " PTR_FMT "\n", end, mas_mn(&mas)); }