diff mbox series

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

Message ID 20241127012753.3393-3-richard.weiyang@gmail.com (mailing list archive)
State New
Headers show
Series spanning write related cleanup | expand

Commit Message

Wei Yang Nov. 27, 2024, 1:27 a.m. UTC
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@gmail.com>
CC: Liam R. Howlett <Liam.Howlett@Oracle.com>
CC: Sidhartha Kumar <sidhartha.kumar@oracle.com>
CC: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
---
 lib/maple_tree.c | 6 ++++++
 1 file changed, 6 insertions(+)
diff mbox series

Patch

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;