All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] maple_tree: Fix mas_prev() and mas_find() state handling
@ 2023-01-10 18:18 Liam Howlett
  0 siblings, 0 replies; only message in thread
From: Liam Howlett @ 2023-01-10 18:18 UTC (permalink / raw)
  To: linux-mm, linux-kernel, Andrew Morton, maple-tree
  Cc: Liam Howlett, syzbot+502859d610c661e56545

When mas_prev() does not find anything, set the state to MAS_NONE.

Handle the MAS_NONE in mas_find() like a MAS_START.

Reported-by: syzbot+502859d610c661e56545@syzkaller.appspotmail.com
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
---

This should come before 9df3d25a97ec ("mm: expand vma iterator
interface") in the mm-unstable branch.

 lib/maple_tree.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lib/maple_tree.c b/lib/maple_tree.c
index 7d3131ecd5f8..19d272ee4b78 100644
--- a/lib/maple_tree.c
+++ b/lib/maple_tree.c
@@ -4844,7 +4844,7 @@ static inline void *mas_prev_entry(struct ma_state *mas, unsigned long min)
 
 	if (mas->index < min) {
 		mas->index = mas->last = min;
-		mas_pause(mas);
+		mas->node = MAS_NONE;
 		return NULL;
 	}
 retry:
@@ -5917,6 +5917,7 @@ void *mas_prev(struct ma_state *mas, unsigned long min)
 	if (!mas->index) {
 		/* Nothing comes before 0 */
 		mas->last = 0;
+		mas->node = MAS_NONE;
 		return NULL;
 	}
 
@@ -6007,6 +6008,9 @@ void *mas_find(struct ma_state *mas, unsigned long max)
 		mas->index = ++mas->last;
 	}
 
+	if (unlikely(mas_is_none(mas)))
+		mas->node = MAS_START;
+
 	if (unlikely(mas_is_start(mas))) {
 		/* First run or continue */
 		void *entry;
-- 
2.35.1

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2023-01-10 18:21 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-10 18:18 [PATCH] maple_tree: Fix mas_prev() and mas_find() state handling Liam Howlett

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.