From: Qu Wenruo Date: Wed, 14 Feb 2018 08:09:56 +0000 (+0800) Subject: btrfs-progs: convert/ext2: Fix memory leak caused by handled ext2_filsys X-Git-Tag: upstream/4.16.1~125 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b8e884f1cda145c73115e2ff9dde096d39e199ca;p=platform%2Fupstream%2Fbtrfs-progs.git btrfs-progs: convert/ext2: Fix memory leak caused by handled ext2_filsys Exposed by convert-test with D=asan. Unlike btrfs, ext2fs_close() still leaves its ext2_filsys parameter filled with allocated pointers. It needs ext2fs_free() to free those pointers. Issue: #92 Signed-off-by: Qu Wenruo Signed-off-by: David Sterba --- diff --git a/convert/source-ext2.c b/convert/source-ext2.c index f5ecd8c..b1492c7 100644 --- a/convert/source-ext2.c +++ b/convert/source-ext2.c @@ -95,6 +95,7 @@ static int ext2_open_fs(struct btrfs_convert_context *cctx, const char *name) return 0; fail: ext2fs_close(ext2_fs); + ext2fs_free(ext2_fs); return -1; } @@ -179,6 +180,7 @@ static void ext2_close_fs(struct btrfs_convert_context *cctx) cctx->volume_name = NULL; } ext2fs_close(cctx->fs_data); + ext2fs_free(cctx->fs_data); } static u8 ext2_filetype_conversion_table[EXT2_FT_MAX] = {