Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933073AbdLRLyO (ORCPT ); Mon, 18 Dec 2017 06:54:14 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:11953 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932952AbdLRLyL (ORCPT ); Mon, 18 Dec 2017 06:54:11 -0500 From: Yunlong Song To: , , , , CC: , , , , , , Subject: [PATCH v2] fsck.f2fs: check nid range before use to avoid segmentation fault Date: Mon, 18 Dec 2017 19:53:45 +0800 Message-ID: <1513598025-160615-1-git-send-email-yunlong.song@huawei.com> X-Mailer: git-send-email 1.8.5.2 In-Reply-To: <1513319174-114303-1-git-send-email-yunlong.song@huawei.com> References: <1513319174-114303-1-git-send-email-yunlong.song@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.107.193.250] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A010204.5A37AC60.0035,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: d3ea1b5bd789635b8197e46f2e40190f Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 533 Lines: 20 Signed-off-by: Yunlong Song --- fsck/fsck.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fsck/fsck.c b/fsck/fsck.c index 11b8b0b..faf0663 100644 --- a/fsck/fsck.c +++ b/fsck/fsck.c @@ -740,7 +740,7 @@ void fsck_chk_inode_blk(struct f2fs_sb_info *sbi, u32 nid, for (idx = 0; idx < 5; idx++) { u32 nid = le32_to_cpu(node_blk->i.i_nid[idx]); - if (nid != 0) { + if (nid != 0 && IS_VALID_NID(sbi, nid)) { struct node_info ni; get_node_info(sbi, nid, &ni); -- 1.8.5.2