[PATCH 3/4] f2fs: avoid memory leak in f2fs_write_root_inode
From: Chao Yu
Date: Thu Nov 16 2017 - 06:52:23 EST
Before exiting f2fs_write_root_inode, we should free in-there allocated
memory.
Signed-off-by: Chao Yu <yuchao0@xxxxxxxxxx>
---
mkfs/f2fs_format.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c
index d5f39ca3dac4..9fc0398fab65 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.15.0.55.gc2ece9dc4de6