From patchwork Mon Aug 21 14:20:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anastasia Belova X-Patchwork-Id: 136406 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b82d:0:b0:3f2:4152:657d with SMTP id z13csp3089908vqi; Mon, 21 Aug 2023 08:39:29 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGg7YfvLfEL/xpQm/pUBF/irIwcUQ7WXzhplhrlKHTSbs9+PSfF8l16Roxr86xqyZk/I/eU X-Received: by 2002:a05:6a00:1252:b0:68a:5877:bfb1 with SMTP id u18-20020a056a00125200b0068a5877bfb1mr2009383pfi.20.1692632369302; Mon, 21 Aug 2023 08:39:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692632369; cv=none; d=google.com; s=arc-20160816; b=JMVDBXu7SXtKCY5wwMxUanBPppK7Y0Yt0ceFf9aQeRLaCdgOEo336scs4rd6FG0BMQ eJPpzDFkx4L5Ct4h8EU9kugpFiAKiG9a7sOZoOzg1E2coTa6VAReSLuqgB2JcfItx8NW 3IbT7rQPUgd4Xw6rrkvFAaADUcaZ43k6u6Y6H2kPx6Sul7suLIa4kY5ZenbPchasnOQ1 a3Nk9gyDR1OoUD41nAfgE/pGHlcMWfvT9We51RumqLZMdQnJuOUlMy7zNt57OamP/0Ln 8iQK52o+cEjbe43ApX8Z206d/C/GPbRaPPxAfk00FkBrCr/5Fro6+21e7gnEAawnfFWH ezAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=MVBdhKynnIBUxgLjV6QPvV+Rvclc62bs9Goz8coDZ9k=; fh=uAbe0KnPwzdEFYaYA734BVl5YoXJhkV5giRXaT44bhk=; b=rHM51LTp+ZZqflPhCzrWPwhvDiv9LXLkEPPOYPJzRORKThL7n3a9ps6ZJ71Is3Gsdd MaWetEnEVjCCN2oXZ0mhOmog0ZvbXJnZOkmiEh6ExoJus0qlk2yZ2AlrEdR+PUiDPR1m AEhzJ/9WcqJZMwl7q5qInMqfepLECV3mkjZKVg6dnacQAKSA7ETAPc3NJz06OMUIIayV +PI47iubvQ431vEzGRQo6fS2Qk/WU60mSj5XQN7XwRa00wurc55I4gnbVAYERlZ35d6z oA4ABHgNnTSAtcjKtXydVrNT5Cbfz9uhcV2+OsS0MmmdZZZUcS0mAEqYkkakuEspYuVZ KpZA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ca23-20020a056a00419700b0068a683896b9si63358pfb.170.2023.08.21.08.39.09; Mon, 21 Aug 2023 08:39:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235875AbjHUOVk (ORCPT + 99 others); Mon, 21 Aug 2023 10:21:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235872AbjHUOVj (ORCPT ); Mon, 21 Aug 2023 10:21:39 -0400 Received: from mail.astralinux.ru (mail.astralinux.ru [217.74.38.119]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65D1F127; Mon, 21 Aug 2023 07:21:20 -0700 (PDT) Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.astralinux.ru (Postfix) with ESMTP id 4332B1866B0F; Mon, 21 Aug 2023 17:21:17 +0300 (MSK) Received: from mail.astralinux.ru ([127.0.0.1]) by localhost (rbta-msk-vsrv-mail01.astralinux.ru [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id nmMrT0FTAkwZ; Mon, 21 Aug 2023 17:21:16 +0300 (MSK) Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.astralinux.ru (Postfix) with ESMTP id D56661865CA5; Mon, 21 Aug 2023 17:21:16 +0300 (MSK) X-Virus-Scanned: amavisd-new at astralinux.ru Received: from mail.astralinux.ru ([127.0.0.1]) by localhost (rbta-msk-vsrv-mail01.astralinux.ru [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id EwXuEzTsToRB; Mon, 21 Aug 2023 17:21:16 +0300 (MSK) Received: from rbta-msk-lt-106062.astralinux.ru (unknown [10.177.13.132]) by mail.astralinux.ru (Postfix) with ESMTPSA id B6EF518668CE; Mon, 21 Aug 2023 17:21:14 +0300 (MSK) From: Anastasia Belova To: Johannes Weiner Cc: Anastasia Belova , Michal Hocko , 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: [PATCH] mm: memcomtrol: add warning in case of rtpn = NULL Date: Mon, 21 Aug 2023 17:20:51 +0300 Message-Id: <20230821142051.31889-1-abelova@astralinux.ru> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1774853679312506878 X-GMAIL-MSGID: 1774853679312506878 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 --- 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;