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@xxxxxxxxx> CC: Liam R. Howlett <Liam.Howlett@xxxxxxxxxx> CC: Sidhartha Kumar <sidhartha.kumar@xxxxxxxxxx> CC: Lorenzo Stoakes <lorenzo.stoakes@xxxxxxxxxx> --- 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