[2/3] mm/damon/sysfs-schemes: handle tried regions sysfs directory allocation failure
Message ID | 20231106233408.51159-3-sj@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp2991854vqu; Mon, 6 Nov 2023 15:34:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IGeoEPsvtK5j+o7tQjnbZFSYWMeY+mNU2gaAKjxkX+J+Li8Q7mJcjcRGKkTNwRToW5tT0y7 X-Received: by 2002:a05:6358:2917:b0:168:dd37:172d with SMTP id y23-20020a056358291700b00168dd37172dmr38963955rwb.20.1699313661037; Mon, 06 Nov 2023 15:34:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699313660; cv=none; d=google.com; s=arc-20160816; b=cCOiNDKzz4CXXynI2ZYMupyom0koLfKEQlKJyNbTcsU+cui80GX0CfuXBOuCtTCzc0 gJr9rNryX1TnWOkAijbkSR2JU1mlgQCBxbtcu0gmFAuyQFUGB1aotcwVCtjBWbrcVfuw TedreKvyRNPTvQPjrJzzYiF3COI522oh1cEg/jfihjnnAVRU7/pa67J14QV0Fu6G5lwr kAXUO14vLAIInb6F2EV+Ax2cdfrBl5dW8PXivOugkQw+btm30ruHq7oeL4hJq1yI7GcU WtAHGPhWO+44cTNsm7xnzVTtlYAwNNG7YDR0K7oOY8QQJjShtK7sQ3mzdY4wgCK4Y/b7 l2WQ== 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 Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id v10-20020a63610a000000b0058a4883e6casi789431pgb.225.2023.11.06.15.34.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 15:34:20 -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 2D824810439B; Mon, 6 Nov 2023 15:34:20 -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 S233412AbjKFXeR (ORCPT <rfc822;heyuhang3455@gmail.com> + 33 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 <rfc822;linux-kernel@vger.kernel.org>); 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 <sj@kernel.org> To: Andrew Morton <akpm@linux-foundation.org> Cc: SeongJae Park <sj@kernel.org>, 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: <linux-kernel.vger.kernel.org> 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:20 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781859521477232148 X-GMAIL-MSGID: 1781859521477232148 |
Series |
mm/damon/sysfs: fix unhandled return values
|
|
Commit Message
SeongJae Park
Nov. 6, 2023, 11:34 p.m. UTC
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: <stable@vger.kernel.org> # 6.2.x
Signed-off-by: SeongJae Park <sj@kernel.org>
---
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;