Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp4059670pxb; Mon, 30 Aug 2021 17:56:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy4DY8SIur9qP/MCP5AYpQ7A9FYjqEBmqjmfAiX/5Nrr5p+34L013xrR0bISUaYZx74AkVA X-Received: by 2002:a02:946d:: with SMTP id a100mr341265jai.118.1630371375531; Mon, 30 Aug 2021 17:56:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630371375; cv=none; d=google.com; s=arc-20160816; b=0vkpxLisrR6pO+ytDV7j6YofDZuSMr5J997lZnJSgCAxvqfG3S1bgt51x/tbKqgBch Pt5uBMfzIAHgkDO8bY1m7Ejy3ggnFKfMlPNi+1IjjwONLTpqgS6bR6M1bpqXfWgD8eMN NZB0i/3w9GoIOK7KLfjjJZ8cIu01ccZb/GyxzFCxHyp9kd0QxPOLEjamRi3jYDLJqvqD Pf9QBEqkn5pWMvKRnQDCe2RfLkrM6wPzW4+LKWghQ/ctMmPiFyXFW0guC7I9UEDnUYAX f9wh0Rzcoj/wwQh/FyXb3Y74qGuTMo/LWcN0+5xLDEPwWYGSV5Ct5muwF1kCWHpoJq9T uH/A== 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=66MOhctBohnV7wvCMd1/bq5Lk7HMv2rZhQVVuO0729s=; b=xLzqBzoThkwFsxl98r642wQgOh4so+RSCfWDpgEz+LuaUgIQlsjDf3Hq7D0tG4ZC1D cvJBghzXMCQ9OtRnSK9LL7cWOCqxqGrwKL2GUj9jeENfBAPG0IgUW/aarO1pzsTH3co/ Qr1LViNn16VrD3++sxmWR42I8YFNpjoCnIxecGTGjlhOBtMO7PGVRKGGJWG+sFtst2Go DfmzeDZIycmnJxMfEIFwH59AAWc//UxZRjzC/1vfAUNOgDxq2NF9kAiV0yPUgSMo5t70 gfOjeLDFf/GskkzzEHRGfRE17/brkqvY48eECHqLYmAf2rXMvk3XugfOn0jmnR6Yecyy OABQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=kbsDjgF4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h11si16498126ild.67.2021.08.30.17.56.03; Mon, 30 Aug 2021 17:56:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=kbsDjgF4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S239230AbhHaAyp (ORCPT + 99 others); Mon, 30 Aug 2021 20:54:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:53190 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231989AbhHaAyn (ORCPT ); Mon, 30 Aug 2021 20:54:43 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E499A60FF2; Tue, 31 Aug 2021 00:53:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1630371229; bh=wBfoW5VjwX94tcmf1r6pB9v16U5JrskEzJHYSKjraeA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kbsDjgF4iL4PUIHG0HoCvJiey/CrxhSgz64wChmx8LYG+bVhTon7os6IsuNZirvRz YandMPLGIx9SEZvQL8C3AzBJVVCiU/L8U6TSzGZ0LDiiVzWtfcg33ExaBw3MqTRmtn NJP2a8hktUNxs72et2K904CfeaJHLfmcUWrPbg61rMZoG5P0AwK1aU1HN2ALtL5bWp 3fVG20HP+dmaezpLzyvEPZOLDLGmFqXr+4R7uWpidqfDfbOMb3nTGy1lGl8zLt28/9 HX6FPUpdG9SfMCYPznYdh6K8UoebkRyxldHQRHphVsepPRNcYHlPeDcU1KFc4ZYm7v 2MbMVD4/RTmrA== From: Jaegeuk Kim To: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Cc: Jaegeuk Kim Subject: [PATCH 2/2] f2fs: should put a page beyond EOF when preparing a write Date: Mon, 30 Aug 2021 17:53:46 -0700 Message-Id: <20210831005346.118701-2-jaegeuk@kernel.org> X-Mailer: git-send-email 2.33.0.259.gc128427fd7-goog In-Reply-To: <20210831005346.118701-1-jaegeuk@kernel.org> References: <20210831005346.118701-1-jaegeuk@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The prepare_compress_overwrite() gets/locks a page to prepare a read, and calls f2fs_read_multi_pages() which checks EOF first. If there's any page beyond EOF, we unlock the page and set cc->rpages[i] = NULL, which we can't put the page anymore. This makes page leak, so let's fix by putting that page. Signed-off-by: Jaegeuk Kim --- fs/f2fs/data.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index 8e8824605f83..41d29382eced 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -2183,6 +2183,8 @@ int f2fs_read_multi_pages(struct compress_ctx *cc, struct bio **bio_ret, continue; } unlock_page(page); + if (for_write) + put_page(page); cc->rpages[i] = NULL; cc->nr_rpages--; } -- 2.33.0.259.gc128427fd7-goog