From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 332F1EE4996 for ; Mon, 21 Aug 2023 14:30:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235993AbjHUOai (ORCPT ); Mon, 21 Aug 2023 10:30:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51472 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235987AbjHUOag (ORCPT ); Mon, 21 Aug 2023 10:30:36 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1AC02FF; Mon, 21 Aug 2023 07:30:34 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id BF70222C36; Mon, 21 Aug 2023 14:30:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1692628232; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=55pk6v33OK9OzwCS+RZYme2GhdpxeZdl+Vots/3Gr40=; b=NFNkWou9yCKMtM4A+fTSD3pJcYqSXNQY8TuZxWTgaoRkSpFUW609I//QIv5RPncrQuugYP aC2zhVzsiaZyfZal4hA0+E6VzWOEbuZQr1pfsrInz2dmgn1akTWs+mDFG8G0y4q92YtzEm CvVXAIlgPY5z3Vrc8u4B0kTMm7K9GRY= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id A0DB51330D; Mon, 21 Aug 2023 14:30:32 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id h+VNJAh142ROAQAAMHmgww (envelope-from ); Mon, 21 Aug 2023 14:30:32 +0000 Date: Mon, 21 Aug 2023 16:30:31 +0200 From: Michal Hocko To: Anastasia Belova Cc: Johannes Weiner , Roman Gushchin , Shakeel Butt , Muchun Song , Andrew Morton , Vladimir Davydov , 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 Message-ID: References: <20230821142051.31889-1-abelova@astralinux.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230821142051.31889-1-abelova@astralinux.ru> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Nacked-by: Michal Hocko 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