linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Michal Hocko <mhocko@suse.com>
To: Anastasia Belova <abelova@astralinux.ru>
Cc: Johannes Weiner <hannes@cmpxchg.org>,
	Roman Gushchin <roman.gushchin@linux.dev>,
	Shakeel Butt <shakeelb@google.com>,
	Muchun Song <muchun.song@linux.dev>,
	Andrew Morton <akpm@linux-foundation.org>,
	Vladimir Davydov <vdavydov.dev@gmail.com>,
	cgroups@vger.kernel.org, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org
Subject: Re: [PATCH] mm: memcomtrol: add warning in case of rtpn = NULL
Date: Mon, 21 Aug 2023 16:30:31 +0200	[thread overview]
Message-ID: <ZON1B73mUMbAecvO@dhcp22.suse.cz> (raw)
In-Reply-To: <20230821142051.31889-1-abelova@astralinux.ru>

On Mon 21-08-23 17:20:51, Anastasia Belova wrote:
> kzalloc_node may return NULL. So rtpn should be
> checked before dereference in mem_cgroup_init.

I do not think this is an appropriate fix. If the allocation really
fails (which is essentially impossible as this is an early boot code and
failing 24B req. this early means the system will likely die anyway)
then we will crash on NULL ptr dereference right afterwards so WARN will
not give us anything usefull on top. So either this needs a graceful way
to deal with the allocation failure or considering the previously said
just keep the code alone and teach the tooling that this should be
ignored.

> Found by Linux Verification Center (linuxtesting.org) with SVACE.
> 
> Fixes: 95a045f63d98 ("mm: memcontrol: consolidate memory controller initialization")
> Signed-off-by: Anastasia Belova <abelova@astralinux.ru>

Nacked-by: Michal Hocko <mhocko@suse.com>

Thanks!

> ---
>  mm/memcontrol.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index e8ca4bdcb03c..7998dbf3c7cd 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -7377,6 +7377,7 @@ static int __init mem_cgroup_init(void)
>  		struct mem_cgroup_tree_per_node *rtpn;
>  
>  		rtpn = kzalloc_node(sizeof(*rtpn), GFP_KERNEL, node);
> +		WARN_ON(!rtpn);
>  
>  		rtpn->rb_root = RB_ROOT;
>  		rtpn->rb_rightmost = NULL;
> -- 
> 2.30.2

-- 
Michal Hocko
SUSE Labs


      parent reply	other threads:[~2023-08-21 14:30 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-21 14:20 Anastasia Belova
2023-08-21 14:25 ` Matthew Wilcox
2023-08-21 14:30 ` Michal Hocko [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=ZON1B73mUMbAecvO@dhcp22.suse.cz \
    --to=mhocko@suse.com \
    --cc=abelova@astralinux.ru \
    --cc=akpm@linux-foundation.org \
    --cc=cgroups@vger.kernel.org \
    --cc=hannes@cmpxchg.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=lvc-project@linuxtesting.org \
    --cc=muchun.song@linux.dev \
    --cc=roman.gushchin@linux.dev \
    --cc=shakeelb@google.com \
    --cc=vdavydov.dev@gmail.com \
    /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