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: 13160011 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 65D57C6FD19 for ; Sat, 4 Mar 2023 19:40:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 606666B0073; Sat, 4 Mar 2023 14:40:06 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 58E9E6B0074; Sat, 4 Mar 2023 14:40:06 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 42EAB6B0075; Sat, 4 Mar 2023 14:40:06 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 34B646B0073 for ; Sat, 4 Mar 2023 14:40:06 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id EB6721205E4 for ; Sat, 4 Mar 2023 19:40:05 +0000 (UTC) X-FDA: 80532231570.20.BC2F9EF Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf04.hostedemail.com (Postfix) with ESMTP id 3E3C74000B for ; Sat, 4 Mar 2023 19:40:04 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=kziuyNZu; spf=pass (imf04.hostedemail.com: domain of sj@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1677958804; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=klm7pnrwFn/X2JkkrxJx+ttziTax9gOlsMmofh2ZMFw=; b=8ow6RAcF06hapQ8NvY5ESEhzew/5VfFOWOBbzs+rgbjEUNipGZeXbNYZWKeBB9ORKInv7e JG2UHAi0c6RxKtWmWDKki+7EkgJJY3ufDYalmrpqxLhBkumUMvAbsEK8hgy7mcvd3Miq9c p+nKr09iD1QqCTmf+1R3HviMdubp7Xg= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=kziuyNZu; spf=pass (imf04.hostedemail.com: domain of sj@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1677958804; a=rsa-sha256; cv=none; b=j1sU9d8PKBZD4VvaFHerwrEU7hq14ULlW78T6b4ITPClIOEjVYdKdwzF0Cxtbwbd6Q4paA DZ1EYwn0s3Ljjx1xsqPVRMoMoa708owTeVqyD4YRi/uFLgnrKZx+WZKzxguHc8Ot9y8ADM lou8FTYOda33XXwoiCBLgASQJX1y9+U= 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 ams.source.kernel.org (Postfix) with ESMTPS id C9560B80025; 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-Rspam-User: X-Rspamd-Server: rspam03 X-Stat-Signature: 1qxzwcfqbmadynbnfyce6c4wfiun4agc X-Rspamd-Queue-Id: 3E3C74000B X-HE-Tag: 1677958804-776218 X-HE-Meta: U2FsdGVkX19J15jlbggTJluGJb5ddpOSt8380ySe9bmrv+qX+hRtxh+viCRbGmaFeB8fufc+ewWH8uSGEgBJclCOmjUmp/ImL4Drwf19HE2XVdHzK7aGHS1h7Fn6JN+39wy7GtQveL7m2yJyYgfRWawVsw6Cj0MZ/f8+UE1CGy94Oq64TVai62ry1CkA1QLCeepHUNhhSzBA3T+DjB/s0eti0G+mFMt2cSPkPkkpPZ3kJvQ8MtRXAj6iSHSKReL6x8bb5v0EkwazfKuawUqFdWLxe038F94zkb41jX6B6bD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/aAcxWg69LtW9csTSg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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; }