Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp14248260pxu; Mon, 4 Jan 2021 17:47:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJzxH2wspkYnGb6LaY/4dUWT5+42CUaM658whU/sbN+pG1AoD3IIhx6kMqIK8FTBmh8CNrs3 X-Received: by 2002:a17:906:af75:: with SMTP id os21mr69678594ejb.330.1609811220653; Mon, 04 Jan 2021 17:47:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609811220; cv=none; d=google.com; s=arc-20160816; b=AmKqLKddlb3h74aj3ND0tvzn/CCMhqphXJww9tn8tOjxVTVwFP8Dbh4t1QyRzMp1/1 5odg8LU1WIt0MOXB+F7ga1FQco7TFkTMMUSp5EN7r+zVlJDOvo+yrmcWtxVDJVz+WtS9 v/ghJ9bZ2XbrWBTd/GAdQHbJpQPY5Jeuo1HYKwm4BhPUEHzLamXBzTxrOEMzDXJWH/uj zk0api09X/iE/eOB2QKbB0gVR4yZC7Z4CPko6ky3n6k/f72W8u0LQTdL9YbjQvh4Ffdo yZ0y/B8TDuKLRwwtmgfgdijca6mWDNjfWjU9AnOCTgZJgi3C+jgMC9Ctc15JUfZRKF6l Pg0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=wJF3KY9cW6HjotaN5y0ihKRrAFwMTDglpDkFPCXTvEk=; b=L5EV9PusjfyYmrlBGUvBQRTglibLhv2ey/SIhXzidt9+DqNKCDLLbUNVRBvcMSUkdZ LufuQe+BKcE3j3rD8kTTh5nx+ogqz0f1kZ0gf1SPTVn2T4QJv4Ir9Fgg5R1lw9ugKDMV HaQX5y/vkCP/WLDqVo3Ibt8cMv4DHlNxO1N6DJ1Z3RI2No7fIWv22kV358V4NhCANbaF rYqKC2cW9GNnLwUxv7F0wiY82qpqghEiG6B0dTqWfKALYnRYzkrcl5TWSAV8X/XNn26E AnJFn3l1+34JkVP9OU0lLc7eDNjAvBOU6LVp4du4+I8shXc1wqz/DKz973QLdaeb7pO5 74lg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t5si29979584ejr.740.2021.01.04.17.46.37; Mon, 04 Jan 2021 17:47:00 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727776AbhAEBpM (ORCPT + 99 others); Mon, 4 Jan 2021 20:45:12 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:9712 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726653AbhAEBpL (ORCPT ); Mon, 4 Jan 2021 20:45:11 -0500 Received: from DGGEMS413-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4D8wHr5B5Gzl0DQ; Tue, 5 Jan 2021 09:43:20 +0800 (CST) Received: from [10.136.114.67] (10.136.114.67) by smtp.huawei.com (10.3.19.213) with Microsoft SMTP Server (TLS) id 14.3.498.0; Tue, 5 Jan 2021 09:44:26 +0800 Subject: Re: [f2fs-dev] [PATCH] f2fs: fix null page reference in redirty_blocks To: Daeho Jeong , , , CC: Colin Ian King , Daeho Jeong References: <20210105012826.956800-1-daeho43@gmail.com> From: Chao Yu Message-ID: <904b7677-3655-2e81-52e0-48296cf1c0da@huawei.com> Date: Tue, 5 Jan 2021 09:44:26 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20210105012826.956800-1-daeho43@gmail.com> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.136.114.67] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021/1/5 9:28, Daeho Jeong wrote: > From: Daeho Jeong > > Fixed null page reference when find_lock_page() fails in > redirty_blocks(). > > Signed-off-by: Daeho Jeong > Reported-by: Colin Ian King > Fixes: 5fdb322ff2c2 ("f2fs: add F2FS_IOC_DECOMPRESS_FILE and F2FS_IOC_COMPRESS_FILE") > --- > fs/f2fs/file.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c > index 9e5275716be8..bf6682a52433 100644 > --- a/fs/f2fs/file.c > +++ b/fs/f2fs/file.c > @@ -4060,8 +4060,10 @@ static int redirty_blocks(struct inode *inode, pgoff_t page_idx, int len) > > for (i = 0; i < page_len; i++, redirty_idx++) { > page = find_lock_page(mapping, redirty_idx); > - if (!page) > + if (!page) { > ret = -ENOENT; ret = -ENOMEM; > + continue; How about breaking the loop for out-of-memory case, because in such condition we have less chance to dirty whole cluster due to no memory, and continue to allocate pages for target file will make system suffer more memory pressure, it will make many thing slower. Thnaks, > + } > set_page_dirty(page); > f2fs_put_page(page, 1); > f2fs_put_page(page, 0); >