fsck.f2fs: check ino of an used nat entry
authorSheng Yong <shengyong1@huawei.com>
Sat, 30 Jan 2016 09:16:38 +0000 (09:16 +0000)
committerJaegeuk Kim <jaegeuk@kernel.org>
Tue, 2 Feb 2016 00:28:15 +0000 (16:28 -0800)
If a nid is valid, the ino in its nat entry should record its parent nid.
However if the ino is zero, we should drop the node.

Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Signed-off-by: Xue Liu <liuxueliu.liu@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fsck/fsck.c

index 7facf07..3e5dd4e 100644 (file)
@@ -358,6 +358,11 @@ static int sanity_check_nid(struct f2fs_sb_info *sbi, u32 nid,
        }
 
        get_node_info(sbi, nid, ni);
+       if (ni->ino == 0) {
+               ASSERT_MSG("nid[0x%x] ino is 0", nid);
+               return -EINVAL;
+       }
+
        if (ni->blk_addr == NEW_ADDR) {
                ASSERT_MSG("nid is NEW_ADDR. [0x%x]", nid);
                return -EINVAL;