From patchwork Sat Mar 4 19:39:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 64263 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp1064260wrd; Sat, 4 Mar 2023 11:47:14 -0800 (PST) X-Google-Smtp-Source: AK7set99d212yOoGBLVyeJOz41lXshN467L3y1hPMPl2eEd2fYOeJpAuLt1jBYD6gMxVipke2oAy X-Received: by 2002:a17:90b:4c43:b0:237:cbcb:efba with SMTP id np3-20020a17090b4c4300b00237cbcbefbamr6578142pjb.17.1677959234659; Sat, 04 Mar 2023 11:47:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677959234; cv=none; d=google.com; s=arc-20160816; b=RtxMGEo7WJtqoS0WnZ+ZlpaPJ5vX3mH8hfDmxsbERYFrkrHmK3auIj6moHsM7ho5vp dLdkHyxYjdn9kWJ7YBC+oZaFVWGH5oIEAqx+uDw5CpdMnkEWTf0R/a2SAyMMDTszfb56 ovoupDSU3JXyGmGs1/tVN/0q8LmwUvY298wujDJ6iOOyGmgRY84bd44IOdYGkY3iOisX GjJ11byubVUuuDqs9Dd6YCBuRrXP22qcEg54ZhcUPe9fyHVmlvXX2zS89lGDL4WPUk9+ Jjvx5kraFUwOxHU6kJD2gqkv+Ya6ahWHwqw3XbsFyNuddjHcGkkweHa4VlHXPQbiVR7N quig== 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=klm7pnrwFn/X2JkkrxJx+ttziTax9gOlsMmofh2ZMFw=; b=LBzOCLLMAsEQHLRBI8WTiO6qPtQ3ac7C+TGRheI8Bn6tqyJExDDF4PWVUSrkNFSKqq f9fSFHi41WIFRzKwtOBx6U6CbBHEAxzfdL1mP8+ArJsix6zARH4/S7QEgjWLkPh3Ib7k iBWm1qPz67vAlFxHdx/bLQGH+c/NcwbljXIWpNYP/6R7OMmGFYOLX6VRu2gp7FyMHceu bS5ghMhhzL+BmWe6gYgY5Oh0cFSxddgFbQUreSpkBXAm/Sa4f7fU3G75Zfw8htoRCGkj NQnGBzqUlTeIs9Fb+kP5l6jA85QoxhPlzQM1dhkdjYA9YQ9IA2j4kx+86tE6NhsDNWb8 iNfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=kziuyNZu; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h2-20020a17090a3d0200b00233d3b31b61si7562733pjc.140.2023.03.04.11.47.02; Sat, 04 Mar 2023 11:47:14 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=kziuyNZu; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229567AbjCDTkG (ORCPT + 99 others); Sat, 4 Mar 2023 14:40:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229615AbjCDTkD (ORCPT ); Sat, 4 Mar 2023 14:40:03 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82014CC34; Sat, 4 Mar 2023 11:40:02 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 0D2E760A65; Sat, 4 Mar 2023 19:40:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DCE5FC4339B; Sat, 4 Mar 2023 19:40:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1677958801; bh=+0s3q5P93UqG6M+TlQeZxhgJ5LHMlSIa1orOsWRdKV4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kziuyNZuajLhSjnjdZnm8IqkuHkf02BiKBZNeQC+XzR3qFQ2pMIvgf0HFTNa9ZvIU MiXIATlC5kNsCUH2IkV3+WpY+nfN1Et1hC77JdpBgeKoTLn/HW0Ki4lmvtt1zPIJNL hYKnvMg2LwM4bqzO6VLrDXgwcM5tSxgINdUbiPlqsy10b8o5tOTdX6A3qIKpyDDJcN zqsNJd4/fgyJ3UYj1S4AzQdJDyXfrsZxRc8y8fmEk6fxnmS6dBIJ1aLQGYaT6jB3P5 K4/8VIcDCSdpIZ11RUrXZOd8tV5KMmXciw/36gYjhopIQHHvdgbUSEye2jFUZsSZ9w JWulLNMHHCudA== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , Kefeng Wang , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH 1/2] mm/damon/paddr: fix folio_size() call after folio_put() in damon_pa_young() Date: Sat, 4 Mar 2023 19:39:48 +0000 Message-Id: <20230304193949.296391-2-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230304193949.296391-1-sj@kernel.org> References: <20230304193949.296391-1-sj@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759467782544516227?= X-GMAIL-MSGID: =?utf-8?q?1759467782544516227?= damon_pa_young() is accessing a folio via folio_size() after folio_put() for the folio has invoked. Fix it. Fixes: 397b0c3a584b ("mm/damon/paddr: remove folio_sz field from damon_pa_access_chk_result") Cc: # 6.3.x Signed-off-by: SeongJae Park Reviewed-by: Matthew Wilcox (Oracle) Reviewed-by: Kefeng Wang --- mm/damon/paddr.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c index 3fda00a0f786..10f159b315ea 100644 --- a/mm/damon/paddr.c +++ b/mm/damon/paddr.c @@ -130,7 +130,6 @@ static bool damon_pa_young(unsigned long paddr, unsigned long *folio_sz) accessed = false; else accessed = true; - folio_put(folio); goto out; } @@ -144,10 +143,10 @@ static bool damon_pa_young(unsigned long paddr, unsigned long *folio_sz) if (need_lock) folio_unlock(folio); - folio_put(folio); out: *folio_sz = folio_size(folio); + folio_put(folio); return accessed; }