Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2029819imu; Fri, 23 Nov 2018 03:46:59 -0800 (PST) X-Google-Smtp-Source: AJdET5ePaCc73XQdjrg59J920ACrjIlEhgWwqNXuzyLv4sfSQ/Qr9y4VRgm+Co0nop29KTtvz+HC X-Received: by 2002:a62:7a8b:: with SMTP id v133mr15887489pfc.159.1542973619705; Fri, 23 Nov 2018 03:46:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542973619; cv=none; d=google.com; s=arc-20160816; b=ms1/Boj3Ma0EZXFrHvw0CtD/U5KAU6VNEtqfOXUZeX16mbNFcOukg6wajvCs7lFE1x AIs+ZUlJI7GX8WoxE+ubCS9wk3GrQN8aks8hVEMd3am7t+tOiAQlFC3WhhnDg0cEyPeD AsK1f6tfRjYIyQtWsq+z61kmBqgOAhnHQQpnx71eB7BTtwobWmjNmZRiTFw7F2UZaiFE zKY5/3p2ru29anasGDOLlkTEd4X70+3OX0Nap2Cua+sFQ/cvvsynGK6wgOP0hLaJ9sE6 +Aep9CYveAR4R3S5isppWR30nzVA7/xpEbBkMvDRAskQcaj0Tb7ghMl8K7+DLZLEoFru PBJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=aClJPX8egxi1YmcUD5svqn+icjHahKdxQJbe/meIE4Y=; b=svGKwXqQ30GiD9ylRSRF8guYFmtzeuVdZqD8cVaAZQP7IgbHttOgkef2JrG53+kGj1 kn0bAX9Q559lbmqoJTXMrfcjEfwOH9HbBPFUEIyufnGR5p2chuPkGcLSvhwTuDY8CDJw GdqFO+NMfXNK7uSqDoiz220R0Wvcl8viwerFlL79bNyKQGXt0yIEKqje1S7NSHkrfVpZ gaHBywgAcWD+3JG2+rYFBJYBuMHJ74i+AW2FhniOoOfkYqqJprZzmuIr96ElKt7hsU9s vUVq0UzfqinCx4u39KDj2ZRt3id7VP2grLEzCtkTwq/0yT2Jw4oHXh19JmXwyIwm1/ic atAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=mhhomcu0; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l7si21775952pfg.245.2018.11.23.03.46.43; Fri, 23 Nov 2018 03:46:59 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=mhhomcu0; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405434AbeKVVif (ORCPT + 99 others); Thu, 22 Nov 2018 16:38:35 -0500 Received: from m12-13.163.com ([220.181.12.13]:43218 "EHLO m12-13.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732079AbeKVVie (ORCPT ); Thu, 22 Nov 2018 16:38:34 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=aClJPX8egxi1YmcUD5 svqn+icjHahKdxQJbe/meIE4Y=; b=mhhomcu0TAYxRn3srVClvk3+OxZx3T+GnG UIPqdu9gGmegksLjivYvCddk4ggpYnVjUzk4btF2ezsI+xZxM6A1IV0KTFBbxF8b 4hTZkz5iJ/ZjVrEb2/42svSMHzTjC/YVOPBJ7WRXbMzgT0na4o0Lluphopkfkt3t S8I0FaeyQ= Received: from bp.localdomain (unknown [106.120.213.96]) by smtp9 (Coremail) with SMTP id DcCowAAnPCXni_Zb588gBQ--.32863S3; Thu, 22 Nov 2018 18:58:54 +0800 (CST) From: Pan Bian To: Jaegeuk Kim , Chao Yu Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, Pan Bian Subject: [PATCH] f2fs: read page index before freeing Date: Thu, 22 Nov 2018 18:58:46 +0800 Message-Id: <1542884326-74903-1-git-send-email-bianpan2016@163.com> X-Mailer: git-send-email 2.7.4 X-CM-TRANSID: DcCowAAnPCXni_Zb588gBQ--.32863S3 X-Coremail-Antispam: 1Uf129KBjvdXoWrtr4DAryfJryDZr1rKrWfXwb_yoWkGrg_Jw 1kZ3yvgFW8Kr1fGan0y3sxJryvyr40gr47W342k3W5tw1rJrZ8AFs8Jrn3Ga4DWr47X34U Crs8tw13uF4fCjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IUnjLvtUUUUU== X-Originating-IP: [106.120.213.96] X-CM-SenderInfo: held01tdqsiiqw6rljoofrz/xtbBUQ4HclaD0RNDpAAAsa Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The function truncate_node frees the page with f2fs_put_page. However, the page index is read after that. So, the patch reads the index before freeing the page. Signed-off-by: Pan Bian --- fs/f2fs/node.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c index d338740..88be946 100644 --- a/fs/f2fs/node.c +++ b/fs/f2fs/node.c @@ -826,6 +826,7 @@ static int truncate_node(struct dnode_of_data *dn) struct f2fs_sb_info *sbi = F2FS_I_SB(dn->inode); struct node_info ni; int err; + pgoff_t index; err = f2fs_get_node_info(sbi, dn->nid, &ni); if (err) @@ -845,10 +846,11 @@ static int truncate_node(struct dnode_of_data *dn) clear_node_page_dirty(dn->node_page); set_sbi_flag(sbi, SBI_IS_DIRTY); + index = dn->node_page->index; f2fs_put_page(dn->node_page, 1); invalidate_mapping_pages(NODE_MAPPING(sbi), - dn->node_page->index, dn->node_page->index); + index, index); dn->node_page = NULL; trace_f2fs_truncate_node(dn->inode, dn->nid, ni.blk_addr); -- 2.7.4