Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp2468241rdf; Mon, 6 Nov 2023 15:34:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IF6poahqcUTv0ffmRW3+vi2/Top5e3txj+wGrMNv0OlmLAOab1LcgQlsxuNG6i9jspTlbgL X-Received: by 2002:a05:6870:a2cd:b0:1e9:d8a4:551f with SMTP id w13-20020a056870a2cd00b001e9d8a4551fmr1343983oak.17.1699313662561; Mon, 06 Nov 2023 15:34:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699313662; cv=none; d=google.com; s=arc-20160816; b=f45gKS+1MbBDvsJi4nl3LI0NhC6WPtmvaDHBi4Tc04X0CeZD8Mzc2DdRBn/z1SERwk K1NznGxuZ9yfi9oWsDILXWC1Wl5sp+V65fO8DJyEMEghM4A19Tu2svz/Pd2WE7cwJG2k w7R/qgLQXcMK7sXOn7+F7vPBMUdYy/17XAN2UWitYG5OZU+Qzfjk5RGp/aZrd1H4RUmV l8tyNXtqZhWJcOFq6kblg+7vp0CeqwPiJXxF9KJhRR0fRw3PC/zkJDqVdBLTroWxxtVF /CqhR12MGhu3v4/bcOeGLwnP2WXdV7q0IjgNnN3WfucYNN/qFciNY3gyd5DP0POz0SgP w7QQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=w0kEAmDIiB+nNiOxil7eazkNdbm+gUZoY9qzJclbFfs=; fh=WXAAPMfSxLmsB2WJ8A0s7FPd+eTotx5bYas/XF5lzN4=; b=ZPFrAOrlalcbmu0H1zrJJRz3on1aCH440aLtcgWPfwVlLkbfcJx1n/vbBgo19pLWSK p2qhCYTT4Q7USE0s18BSR42cn2hvzZ6bthxdI63bBAIUI/Y4LL71OT3e6WOY99x778zm CIeuwic9PCSBGU+kt5ED7bbKH+XD53T66Z2+Cf2ESgBtofkhpMXZ3qPVHrp1+hvd4Mev RAXoNd+wjGCHBT9xN+cd3isBLDzjM5X7BoFe5xXMmjJyKYEosvtoaseHLIqyYJxz6hYL 2pUmknqscS8WCKg0wExEOkQrHCfGVNCQhhZYLUVprfSgc3onJBHU9tmrjKPb6liqeX9C iSZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=l7EqwQOv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id bt7-20020a056a00438700b0068e3b121545si9344006pfb.58.2023.11.06.15.34.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 15:34:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=l7EqwQOv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 6C641810439A; Mon, 6 Nov 2023 15:34:21 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233409AbjKFXeR (ORCPT + 99 others); Mon, 6 Nov 2023 18:34:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233383AbjKFXeP (ORCPT ); Mon, 6 Nov 2023 18:34:15 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1C8583; Mon, 6 Nov 2023 15:34:12 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2B5E5C433C7; Mon, 6 Nov 2023 23:34:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1699313652; bh=W1YiwkaUjwsrSNghKHLS4esY06g2LoID2WDuKt3I9RI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=l7EqwQOv3ujXdIdXqqLv7Yl2LZRZP4XIrLtoom+8gJLK5oV+OiHLT+vhbC/H1l//N 3ys60zJfeXmo1OBsPoTrzHX39yAklgEWMZGpaL5dQ84d1Wm494msHCkhjxa3lLv/o+ bmlBz1f8LPIrbknFW1iBJdvA5QQacQ1blL3tn2CUS9dsVOdkdhD3h1h9hzWsXsD+lD cQcF6kLh9zlF7uEHKE33vL0PahvmSow2SGpG0LP18EhMlmxAFu7oZpV7nWkVBLUK+y KXwSQej944ZLmBtdEJft4FhJiRYzEA2O1R8i/uGHUKVQC5EUGKH8wVyaId3jKSixkj qTvuPBpthovEA== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH 2/3] mm/damon/sysfs-schemes: handle tried regions sysfs directory allocation failure Date: Mon, 6 Nov 2023 23:34:07 +0000 Message-Id: <20231106233408.51159-3-sj@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231106233408.51159-1-sj@kernel.org> References: <20231106233408.51159-1-sj@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 06 Nov 2023 15:34:21 -0800 (PST) DAMOS tried regions sysfs directory allocation function (damon_sysfs_scheme_regions_alloc()) is not handling the memory allocation failure. In the case, the code will dereference NULL pointer. Handle the failure to avoid such invalid access. Fixes: 9277d0367ba1 ("mm/damon/sysfs-schemes: implement scheme region directory") Cc: # 6.2.x Signed-off-by: SeongJae Park --- mm/damon/sysfs-schemes.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c index 45bd0fd4a8b1..7413cb35c5a9 100644 --- a/mm/damon/sysfs-schemes.c +++ b/mm/damon/sysfs-schemes.c @@ -162,6 +162,9 @@ damon_sysfs_scheme_regions_alloc(void) struct damon_sysfs_scheme_regions *regions = kmalloc(sizeof(*regions), GFP_KERNEL); + if (!regions) + return NULL; + regions->kobj = (struct kobject){}; INIT_LIST_HEAD(®ions->regions_list); regions->nr_regions = 0; -- 2.34.1