f2fs-tools: fix potential deadloop
authorChao Yu <yuchao0@huawei.com>
Fri, 9 Aug 2019 10:52:53 +0000 (18:52 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Tue, 27 Aug 2019 21:51:05 +0000 (14:51 -0700)
In error path of build_sit_info(), start variable is unsigned int type,
it should never be less than zero, fix it.

build_sit_info()
{
...
unsigned int start;
...
free_validity_maps:
for (--start ; start >= 0; --start)
free(sit_i->sentries[start].cur_valid_map);
...
}

Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fsck/mount.c

index e5f7f3b..f69df87 100644 (file)
@@ -1404,7 +1404,8 @@ int build_sit_info(struct f2fs_sb_info *sbi)
        struct f2fs_super_block *sb = F2FS_RAW_SUPER(sbi);
        struct f2fs_checkpoint *cp = F2FS_CKPT(sbi);
        struct sit_info *sit_i;
-       unsigned int sit_segs, start;
+       unsigned int sit_segs;
+       int start;
        char *src_bitmap, *dst_bitmap;
        unsigned int bitmap_size;