diff mbox

btrfs-progs: convert/ext2: Fix memory leak caused by handled ext2_filsys

Message ID 20180214080956.9953-1-wqu@suse.com (mailing list archive)
State New, archived
Headers show

Commit Message

Qu Wenruo Feb. 14, 2018, 8:09 a.m. UTC
Exposed 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.

Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 convert/source-ext2.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

David Sterba Feb. 14, 2018, 3:37 p.m. UTC | #1
On Wed, Feb 14, 2018 at 04:09:56PM +0800, Qu Wenruo wrote:
> Exposed 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.
> 
> Signed-off-by: Qu Wenruo <wqu@suse.com>

Applied, thanks.
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/convert/source-ext2.c b/convert/source-ext2.c
index e9277213b77a..67e97cf87185 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] = {