]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
maple_tree: Handle MAS_NONE and MAS_PAUSE in mas_walk()
authorLiam R. Howlett <Liam.Howlett@oracle.com>
Fri, 10 Feb 2023 21:47:25 +0000 (16:47 -0500)
committerLiam R. Howlett <Liam.Howlett@oracle.com>
Mon, 13 Feb 2023 13:42:04 +0000 (08:42 -0500)
When walking the tree, handle MAS_NONE and MAS_PAUSE the same as
MAS_START.

This also fixes a potential error returned when re-walking a single
entry tree of 0 - 0.

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
lib/maple_tree.c

index 35c0f07f1e01cf0cee3d48bd4234751fe1c33ee7..7783e7e7b59c3fc78a74c0bd5373b0282a1b7cf8 100644 (file)
@@ -5027,6 +5027,8 @@ void *mas_walk(struct ma_state *mas)
 {
        void *entry;
 
+       if (mas_is_none(mas) || mas_is_paused(mas))
+               mas->node = MAS_START;
 retry:
        entry = mas_state_walk(mas);
        if (mas_is_start(mas))
@@ -5035,6 +5037,8 @@ retry:
        if (mas_is_ptr(mas)) {
                if (!mas->index) {
                        mas->last = 0;
+                       if (!entry)
+                               entry = mas_root(mas);
                } else {
                        mas->index = 1;
                        mas->last = ULONG_MAX;