From d17426964639cb440256dd70a1e3cdf36eebf019 Mon Sep 17 00:00:00 2001 From: Liu Xue Date: Mon, 14 Dec 2015 11:31:28 +0000 Subject: fsck.f2fs: deal with realloc size and realloc failure Deal with realloc failure to avoid memory leak and memory free, and assert realloc size to avoid double free for tree_mark. Change-Id: I39fef4d4d03eeb8334f5d4899701a2d1a3852588 Signed-off-by: Xue Liu Signed-off-by: Jaegeuk Kim --- fsck/fsck.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fsck/fsck.c b/fsck/fsck.c index 63ee914..58786f2 100644 --- a/fsck/fsck.c +++ b/fsck/fsck.c @@ -892,7 +892,9 @@ static void print_dentry(__u32 depth, __u8 *name, if (tree_mark_size <= depth) { tree_mark_size *= 2; + ASSERT(tree_mark_size != 0); tree_mark = realloc(tree_mark, tree_mark_size); + ASSERT(tree_mark != NULL); } if (last_de) @@ -1256,6 +1258,7 @@ void fsck_init(struct f2fs_sb_info *sbi) build_sit_area_bitmap(sbi); + ASSERT(tree_mark_size != 0); tree_mark = calloc(tree_mark_size, 1); ASSERT(tree_mark != NULL); } -- cgit v1.2.3