[PATCH v4 02/49] maple_tree: Fix potential rcu issue

From: Liam R. Howlett
Date: Fri Jan 20 2023 - 11:27:34 EST


From: "Liam R. Howlett" <Liam.Howlett@xxxxxxxxxx>

Ensure the node isn't dead after reading the node end.

Signed-off-by: Liam R. Howlett <Liam.Howlett@xxxxxxxxxx>
---
lib/maple_tree.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/maple_tree.c b/lib/maple_tree.c
index cb8c03c4dce7..cbb8bd9b9d25 100644
--- a/lib/maple_tree.c
+++ b/lib/maple_tree.c
@@ -4654,13 +4654,13 @@ static inline void *mas_next_nentry(struct ma_state *mas,
pivots = ma_pivots(node, type);
slots = ma_slots(node, type);
mas->index = mas_safe_min(mas, pivots, mas->offset);
+ count = ma_data_end(node, type, pivots, mas->max);
if (ma_dead_node(node))
return NULL;

if (mas->index > max)
return NULL;

- count = ma_data_end(node, type, pivots, mas->max);
if (mas->offset > count)
return NULL;

--
2.35.1