Skip to contentSkip to conversation

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

PATCH Applied Qu Wenruo 2 participants 2 messages Feb 14, 2018 Btrfs file system

lore
Share & tools
lore

Qu Wenruo

author
#0 lore raw

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

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.

---
 convert/source-ext2.c | 2 ++
 1 file changed, 2 insertions(+)
convert/source-ext2.c +2 -0
index e9277213b77a..67e97cf87185 100644
@@ -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] = {
Signature · 1 line
2.16.1
Applied
#1 lore raw
Quoted 8 lines · Qu Wenruo

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.

Applied, thanks.