From: Liam 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=ef26a882853669eabbf471ce6ab82522efe526f3;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 Howlett --- diff --git a/lib/maple_tree.c b/lib/maple_tree.c index de6fb61bb63b..993ced44aad2 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -4859,6 +4859,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];