linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
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>,
	linux-kernel@vger.kernel.org, maple-tree@lists.infradead.org,
	linux-mm@kvack.org, Josh Law <objecting@objecting.org>
Subject: Re: [PATCH v2] lib/maple_tree: fix potential NULL dereference in mas_pop_node()
Date: Tue, 31 Mar 2026 23:27:20 -0400	[thread overview]
Message-ID: <uiq2elysm7osapc2rr6rcyqwfofqmuxn4fg4kgp3i6ltwdj33l@z3azyih67up2> (raw)
In-Reply-To: <20260313073132.159184-1-objecting@objecting.org>

* Josh Law <hlcj1234567@gmail.com> [260313 03:31]:
> If kmem_cache_alloc_from_sheaf() returns NULL (possible under
> GFP_NOWAIT pressure), mas_pop_node() falls through to the out label
> and dereferences the NULL pointer in memset(ret, 0, sizeof(*ret)).
> 
> Add a NULL check after the sheaf allocation to bail out early.
> 
> Signed-off-by: Josh Law <objecting@objecting.org>
> ---
> v2: drop WARN_ON_ONCE — this is a recoverable allocation failure,
>     not a state that warrants a warning splat.
> 
>  lib/maple_tree.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/lib/maple_tree.c b/lib/maple_tree.c
> index 739918e859e5..1eaaa5f964e9 100644
> --- a/lib/maple_tree.c
> +++ b/lib/maple_tree.c
> @@ -1063,6 +1063,8 @@ static __always_inline struct maple_node *mas_pop_node(struct ma_state *mas)
>  		return NULL;
> 
>  	ret = kmem_cache_alloc_from_sheaf(maple_node_cache, GFP_NOWAIT, mas->sheaf);
> +	if (!ret)
> +		return NULL;
> 

This isn't necessary, as explained to v1 after this was sent, I think?

What a mess.  I'm objecting.

Liam


      reply	other threads:[~2026-04-01  3:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-13  7:31 Josh Law
2026-04-01  3:27 ` Liam R. Howlett [this message]

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=uiq2elysm7osapc2rr6rcyqwfofqmuxn4fg4kgp3i6ltwdj33l@z3azyih67up2 \
    --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