[PATCH 2/7] maple_tree: validate we won't split on NULL

Wei Yang richard.weiyang at gmail.com
Tue Nov 26 17:27:48 PST 2024


If this is not the right most node, we don't expect its last slot to be
NULL.

Let's validate this.

Signed-off-by: Wei Yang <richard.weiyang at gmail.com>
CC: Liam R. Howlett <Liam.Howlett at Oracle.com>
CC: Sidhartha Kumar <sidhartha.kumar at oracle.com>
CC: Lorenzo Stoakes <lorenzo.stoakes at oracle.com>
---
 lib/maple_tree.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/lib/maple_tree.c b/lib/maple_tree.c
index 98692704d773..2a00441130ee 100644
--- a/lib/maple_tree.c
+++ b/lib/maple_tree.c
@@ -7522,6 +7522,12 @@ static void mt_validate_nulls(struct maple_tree *mt)
 		MT_BUG_ON(mt, !last && !entry);
 		last = entry;
 		if (offset == mas_data_end(&mas)) {
+			if ((mas.max != ULONG_MAX) && !entry) {
+				pr_err("Last slot %p end with NULL\n",
+					mas_mn(&mas));
+				MT_BUG_ON(mas.tree, 1);
+			}
+
 			mas_next_node(&mas, mas_mn(&mas), ULONG_MAX);
 			if (mas_is_overflow(&mas))
 				return;
-- 
2.34.1




More information about the maple-tree mailing list