From bad43e38fc25245b23f18503099f5a728149576a Mon Sep 17 00:00:00 2001 From: Chao Yu Date: Thu, 16 Nov 2017 19:50:57 +0800 Subject: [PATCH] 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 --- mkfs/f2fs_format.c | 3 +++ 1 file changed, 3 insertions(+) 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; } -- 2.7.4