diff options
author | Liam R. Howlett <Liam.Howlett@Oracle.com> | 2023-04-11 18:10:46 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2023-04-13 17:55:39 +0300 |
commit | 0a0372d1d2342ad53676ab039aa0836df81cede4 (patch) | |
tree | e0a12115f2762c368d090c01058ad2d4783a3af2 /lib/maple_tree.c | |
parent | 19d8f782e380c0266b034cf445100361164837b4 (diff) | |
download | linux-0a0372d1d2342ad53676ab039aa0836df81cede4.tar.xz |
maple_tree: fix mas_prev() and mas_find() state handling
commit 17dc622c7b0f94e49bed030726df4db12ecaa6b5 upstream.
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
Cc: <Stable@vger.kernel.org>
Fixes: 54a611b60590 ("Maple Tree: add new data structure")
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
Reported-by: <syzbot+502859d610c661e56545@syzkaller.appspotmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'lib/maple_tree.c')
-rw-r--r-- | lib/maple_tree.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 203bd3e51c98..b72ddea9d277 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: @@ -5906,6 +5906,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; } @@ -5996,6 +5997,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; |