Btrfs-progs: fix Segmentation fault of btrfs-convert
authorLiu Bo <bo.li.liu@oracle.com>
Mon, 7 Jul 2014 14:35:53 +0000 (22:35 +0800)
committerDavid Sterba <dsterba@suse.cz>
Fri, 22 Aug 2014 13:04:50 +0000 (15:04 +0200)
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>
Signed-off-by: David Sterba <dsterba@suse.cz>
volumes.c

index f623a44..388c94e 100644 (file)
--- a/volumes.c
+++ b/volumes.c
@@ -184,12 +184,18 @@ 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);
        }
 
-       list_del(&fs_devices->list);
-       free(fs_devices);
        return 0;
 }