Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp2468321rdf; Mon, 6 Nov 2023 15:34:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IFqXr7APCgjt61zGBx5RGxXv0/ZXaWB4fwsrNtdZA55EOgPQl4Te0DfQdCVKqfq4ydbBKvk X-Received: by 2002:a17:903:22ca:b0:1c7:8446:d65c with SMTP id y10-20020a17090322ca00b001c78446d65cmr28811257plg.43.1699313671997; Mon, 06 Nov 2023 15:34:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699313671; cv=none; d=google.com; s=arc-20160816; b=Ot3YODuhQenuhewWvVnVlOdcN8HqP6TLAMQr/MlQ3A90dza+ByyBuODmjlT5b/Jh5N 3u0xKFGpqq5tFnpwSv3OtimDKmX3oPoY/XQ1WoMal//fATbdERmIBrH1OBjZSRF9mIlP vEn9qIY1KgI540TeY2Nhb3C7RdQPrRbEpX8zwlms3peJ0iWljN/IGm7kW7YblLukIpSd J+nhHCIlpp4YFD8gfSGceUoGMl44nEvq6R185iKc/50nWppKi4SEUHODT4gHbISv58q6 xBpj7PV9s9AsVRP4f+MTPG5AFbqVjFxHS0VB57+UmS140G1Ir/DdLA9gRiMeL0ZZuZaw X84A== 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=ED/5VRqDjeQ3vhbsBXBAmAewjBcby2wVIAxcWWWm3uU=; fh=WXAAPMfSxLmsB2WJ8A0s7FPd+eTotx5bYas/XF5lzN4=; b=zz9qcvY4Ud2eKqIKHeDyjaRSR+HxAEFTypPom31q5ETrDx727x38PSFa2PHWgmuzVz kxVzIvA/MBdwd44Hg/xlwVlU/SZKQ7NZWwX6fKJBaiqvBbfx8qQkQ7+wZDHrqvJ4VE/2 obuRnAAeRmMhXSzYdMx6P2lhB0eXjLWgejHCZTD/kv5vGuENJrKMJV+BGPTPZ9d7l4bt V/cHYkAeFNUV5GgJ6jWhqtCRrzxhF6EHFzsKvos8JixS9yxMK8eKS489t6MDzACcPVI4 zC+PRwkCrlqCRU4E91jG4Gefmt1+bQlHuMEZRSZUG8CaSIOydLUomboWTZL1GenNCTG1 8tHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=D1wTspPU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id b13-20020a170903228d00b001c5e0672f53si10202652plh.466.2023.11.06.15.34.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 15:34:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=D1wTspPU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 49BDD8104512; Mon, 6 Nov 2023 15:34:29 -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 S233466AbjKFXeT (ORCPT + 99 others); Mon, 6 Nov 2023 18:34:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233321AbjKFXeQ (ORCPT ); Mon, 6 Nov 2023 18:34:16 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17C6983; Mon, 6 Nov 2023 15:34:14 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 55F12C433CA; Mon, 6 Nov 2023 23:34:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1699313653; bh=19smz8vjkknnlftKxQDFJP/XhxeknF20W/DyGkIS8Os=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=D1wTspPUeGLo6x8Q/O1NGf9r8R7Y77Rea13Em+t/uPG+M8MB1RkYbqzvbkzEFu/2o +EbJZr5EpmuJNr37DT7pK4w7FQz0S3gGCgTdLEjwu0j0llYH7NAk8oU5KIZyMrGTDa xU8ou+PE7Hw8IjLv9dyB+hxXwQngY+1i+Ioz1CMmAr4QR9KqCjMOtErZW426EoDG0n ZWwH3Jx6nAAnd11/pOFJY9vSHUNoDTRFu1AngsTYsvE2korQlJDZmaQT6CsbPoIwr5 yzi1Mp+MivvdfbKoUGQsKHXEJT583q7JL2Znk9lwUlXiHrruB3lltIK3NLWFk4pDhE SzPy2Mk286CAw== 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 3/3] mm/damon/sysfs-schemes: handle tried region directory allocation failure Date: Mon, 6 Nov 2023 23:34:08 +0000 Message-Id: <20231106233408.51159-4-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:29 -0800 (PST) DAMON sysfs interface's before_damos_apply callback (damon_sysfs_before_damos_apply()), which creates the DAMOS tried regions for each DAMOS action applied region, is not handling the allocation failure for the sysfs directory data. As a result, NULL pointer derefeence is possible. Fix it by handling the case. Fixes: f1d13cacabe1 ("mm/damon/sysfs: implement DAMOS tried regions update command") Cc: # 6.2.x Signed-off-by: SeongJae Park --- mm/damon/sysfs-schemes.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c index 7413cb35c5a9..be667236b8e6 100644 --- a/mm/damon/sysfs-schemes.c +++ b/mm/damon/sysfs-schemes.c @@ -1826,6 +1826,8 @@ static int damon_sysfs_before_damos_apply(struct damon_ctx *ctx, return 0; region = damon_sysfs_scheme_region_alloc(r); + if (!region) + return 0; list_add_tail(®ion->list, &sysfs_regions->regions_list); sysfs_regions->nr_regions++; if (kobject_init_and_add(®ion->kobj, -- 2.34.1