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

Liam R. Howlett Liam.Howlett at oracle.com
Tue Mar 31 20:24:00 PDT 2026


* Josh Law <hlcj1234567 at gmail.com> [260312 14:41]:
> 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().

This should be a function, then.

With a test case, if possible.

> 
> Signed-off-by: Josh Law <objecting at objecting.org>


> ---
>  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
> 



More information about the maple-tree mailing list