summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorLiam R. Howlett <Liam.Howlett@oracle.com>2023-01-20 19:26:07 +0300
committerAndrew Morton <akpm@linux-foundation.org>2023-02-10 03:51:31 +0300
commit17dc622c7b0f94e49bed030726df4db12ecaa6b5 (patch)
treeb86501d97c04ca902b4c191a49f5e0c170f07319 /lib
parent1202700c3f8cc5f7e4646c3cf05ee6f7c8bc6ccf (diff)
downloadlinux-17dc622c7b0f94e49bed030726df4db12ecaa6b5.tar.xz
maple_tree: fix mas_prev() and mas_find() state handling
When mas_prev() does not find anything, set the state to MAS_NONE. Handle the MAS_NONE in mas_find() like a MAS_START. Link: https://lkml.kernel.org/r/20230120162650.984577-7-Liam.Howlett@oracle.com Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com> Reported-by: <syzbot+502859d610c661e56545@syzkaller.appspotmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/maple_tree.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/maple_tree.c b/lib/maple_tree.c
index 7c786bd5e575..5e9703189259 100644
--- a/lib/maple_tree.c
+++ b/lib/maple_tree.c
@@ -4845,7 +4845,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:
@@ -5919,6 +5919,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;
}
@@ -6009,6 +6010,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;