[PATCH 2/3] lib/maple_tree: fix always-true condition in mas_erase()

From: Josh Law

Date: Thu Mar 12 2026 - 14:41:03 EST


The condition (!mas_is_active(mas) || !mas_is_start(mas)) is always
true because ma_active and ma_start are distinct enum values -- a
state can never be both simultaneously. This causes mas_erase() to
unconditionally reset the status to ma_start, discarding a valid
active walk position.

Change || to && so the reset only fires when the state is neither
active nor start, matching the equivalent guard in mas_walk().

Signed-off-by: Josh Law <objecting@xxxxxxxxxxxxx>
---
lib/maple_tree.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/maple_tree.c b/lib/maple_tree.c
index 87a2ba6468ca..9727dcefbf65 100644
--- a/lib/maple_tree.c
+++ b/lib/maple_tree.c
@@ -5574,7 +5574,7 @@ void *mas_erase(struct ma_state *mas)
unsigned long index = mas->index;
MA_WR_STATE(wr_mas, mas, NULL);

- if (!mas_is_active(mas) || !mas_is_start(mas))
+ if (!mas_is_active(mas) && !mas_is_start(mas))
mas->status = ma_start;

write_retry:
--
2.34.1