]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
maple_tree: make mas_erase() more robust
authorLiam R. Howlett <Liam.Howlett@oracle.com>
Wed, 1 Nov 2023 17:16:19 +0000 (13:16 -0400)
committerAndrew Morton <akpm@linux-foundation.org>
Tue, 12 Dec 2023 18:56:57 +0000 (10:56 -0800)
mas_erase() may not deal correctly with all maple states.  Make the
function more robust by ensuring the state is in one of the two acceptable
states.

Link: https://lkml.kernel.org/r/20231101171629.3612299-3-Liam.Howlett@oracle.com
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
Cc: Peng Zhang <zhangpeng.00@bytedance.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
lib/maple_tree.c

index fff94a510fa86c8719e6d763241d9d0691b6d780..8d379d34ea0a764f6cfccba66e7d8966cd9b95bb 100644 (file)
@@ -6173,7 +6173,7 @@ void *mas_erase(struct ma_state *mas)
        void *entry;
        MA_WR_STATE(wr_mas, mas, NULL);
 
-       if (mas_is_none(mas) || mas_is_paused(mas))
+       if (!mas_is_active(mas) || !mas_is_start(mas))
                mas->node = MAS_START;
 
        /* Retry unnecessary when holding the write lock. */