From: "Liam R. Howlett" <Liam.Howlett@oracle.com>
To: Josh Law <hlcj1234567@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Alice Ryhl <aliceryhl@google.com>,
Andrew Ballance <andrewjballance@gmail.com>,
Josh Law <objecting@objecting.org>,
maple-tree@lists.infradead.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/3] lib/maple_tree: fix always-true condition in mas_erase()
Date: Tue, 31 Mar 2026 23:24:00 -0400 [thread overview]
Message-ID: <lma6r3ah4e6v4sreszmbkrcfrxzu7dvhuuzemtkw63v2e6yyj7@a5sys3xfpzpv> (raw)
In-Reply-To: <20260312184054.23481-2-objecting@objecting.org>
* Josh Law <hlcj1234567@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@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
>
next prev parent reply other threads:[~2026-04-01 3:24 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-12 18:40 [PATCH 1/3] lib/maple_tree: fix potential NULL dereference in mas_pop_node() Josh Law
2026-03-12 18:40 ` [PATCH 2/3] lib/maple_tree: fix always-true condition in mas_erase() Josh Law
2026-04-01 3:24 ` Liam R. Howlett [this message]
2026-03-12 20:45 ` [PATCH 1/3] lib/maple_tree: fix potential NULL dereference in mas_pop_node() Andrew Morton
2026-03-12 20:49 ` Josh Law
2026-03-12 20:56 ` Josh Law
2026-03-12 21:14 ` Josh Law
2026-03-12 23:00 ` Alice Ryhl
2026-03-12 23:22 ` Pedro Falcato
2026-03-13 7:17 ` Josh Law
2026-03-13 9:05 ` Pedro Falcato
2026-03-13 16:11 ` Josh Law
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=lma6r3ah4e6v4sreszmbkrcfrxzu7dvhuuzemtkw63v2e6yyj7@a5sys3xfpzpv \
--to=liam.howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=aliceryhl@google.com \
--cc=andrewjballance@gmail.com \
--cc=hlcj1234567@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=maple-tree@lists.infradead.org \
--cc=objecting@objecting.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox