From: Chao Yu Date: Thu, 16 Nov 2017 11:50:57 +0000 (+0800) Subject: f2fs: avoid memory leak in f2fs_write_root_inode X-Git-Tag: v1.10.0~25 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bad43e38fc25245b23f18503099f5a728149576a;p=platform%2Fupstream%2Ff2fs-tools.git f2fs: avoid memory leak in f2fs_write_root_inode Before exiting f2fs_write_root_inode, we should free in-there allocated memory. Signed-off-by: Chao Yu Signed-off-by: Jaegeuk Kim --- diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c index d5f39ca..9fc0398 100644 --- a/mkfs/f2fs_format.c +++ b/mkfs/f2fs_format.c @@ -1042,6 +1042,7 @@ static int f2fs_write_root_inode(void) c.blks_per_seg, main_area_node_seg_blk_offset); if (dev_write_block(raw_node, main_area_node_seg_blk_offset)) { MSG(1, "\tError: While writing the raw_node to disk!!!\n"); + free(raw_node); return -1; } @@ -1052,9 +1053,11 @@ static int f2fs_write_root_inode(void) #ifndef WITH_ANDROID if (discard_obsolete_dnode(raw_node, main_area_node_seg_blk_offset)) { + free(raw_node); return -1; } #endif + free(raw_node); return 0; }