linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Anastasia Belova <abelova@astralinux.ru>
To: Johannes Weiner <hannes@cmpxchg.org>
Cc: Anastasia Belova <abelova@astralinux.ru>,
	Michal Hocko <mhocko@kernel.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: [PATCH] mm: memcomtrol: add warning in case of rtpn = NULL
Date: Mon, 21 Aug 2023 17:20:51 +0300	[thread overview]
Message-ID: <20230821142051.31889-1-abelova@astralinux.ru> (raw)

kzalloc_node may return NULL. So rtpn should be
checked before dereference in mem_cgroup_init.

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



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

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-21 14:20 Anastasia Belova [this message]
2023-08-21 14:25 ` Matthew Wilcox
2023-08-21 14:30 ` Michal Hocko

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=20230821142051.31889-1-abelova@astralinux.ru \
    --to=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=mhocko@kernel.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