diff mbox

Btrfs-progs: fix Segmentation fault of btrfs-convert

Message ID 1404743753-24856-1-git-send-email-bo.li.liu@oracle.com (mailing list archive)
State Accepted
Headers show

Commit Message

Liu Bo July 7, 2014, 2:35 p.m. UTC
Recently we merge a memory leak fix, which fails xfstests/btrfs/012,
the cause is that it only frees @fs_devices but leaves it on the global
fs_uuid list, which cause a 'Segmentation fault' over running command
btrfs-convert.  This fixes the problem.

Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
---
 volumes.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
diff mbox

Patch

diff --git a/volumes.c b/volumes.c
index a61928c..8b827fa 100644
--- a/volumes.c
+++ b/volumes.c
@@ -184,11 +184,17 @@  again:
 	seed_devices = fs_devices->seed;
 	fs_devices->seed = NULL;
 	if (seed_devices) {
+		struct btrfs_fs_devices *orig;
+
+		orig = fs_devices;
 		fs_devices = seed_devices;
+		list_del(&orig->list);
+		free(orig);
 		goto again;
+	} else {
+		list_del(&fs_devices->list);
+		free(fs_devices);
 	}
-
-	free(fs_devices);
 	return 0;
 }