From a64917310ce11fdeec00e1c9fe7c2f1b80ff6034 Mon Sep 17 00:00:00 2001 From: "Liam R. Howlett" Date: Thu, 24 Nov 2022 10:50:21 -0500 Subject: [PATCH] maple_tree: Protect mas_prev_nentry() from dead nodes Don't use the pivot array before checking if the node is dead. This is for safe use in rcu mode. Signed-off-by: Liam R. Howlett --- lib/maple_tree.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index b254b8169694..b846d9ccfa9b 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -4860,6 +4860,11 @@ retry: goto retry; } + if (offset == mt_pivots[mt]) + pivot = mas->max; + else + pivot = pivots[offset]; + while (offset && ((!mas_slot(mas, slots, offset) && pivot >= limit) || !pivot)) pivot = pivots[--offset]; -- 2.49.0