From: Liam R. Howlett Date: Thu, 24 Nov 2022 15:50:21 +0000 (-0500) Subject: maple_tree: Protect mas_prev_nentry() from dead nodes X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=f9eacfb30435ba7f177427e03d15faefa0f62ca9;p=users%2Fjedix%2Flinux-maple.git 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 --- diff --git a/lib/maple_tree.c b/lib/maple_tree.c index d8504912014e..e66ac3a0e47b 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -4856,6 +4856,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];