btrfs-progs: Add all missing btrfs_close_all_devices to standalone tools
authorZhao Lei <zhaolei@cn.fujitsu.com>
Mon, 26 Oct 2015 10:28:20 +0000 (18:28 +0800)
committerDavid Sterba <dsterba@suse.com>
Mon, 2 Nov 2015 08:35:08 +0000 (09:35 +0100)
This patch add all missing btrfs_close_all_devices() to standalone
tools in btrfs progs, to avoid memory leak.

Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
btrfs-calc-size.c
btrfs-debug-tree.c
btrfs-find-root.c
btrfs-map-logical.c
btrfs-select-super.c
btrfstune.c

index 7287858..b756693 100644 (file)
@@ -508,5 +508,6 @@ int main(int argc, char **argv)
 out:
        close_ctree(root);
        free(roots);
+       btrfs_close_all_devices();
        return ret;
 }
index 7d8e876..8adc39f 100644 (file)
@@ -28,6 +28,7 @@
 #include "disk-io.h"
 #include "print-tree.h"
 #include "transaction.h"
+#include "volumes.h"
 #include "utils.h"
 
 static int print_usage(int ret)
@@ -428,5 +429,7 @@ no_node:
        printf("uuid %s\n", uuidbuf);
        printf("%s\n", PACKAGE_STRING);
 close_root:
-       return close_ctree(root);
+       ret = close_ctree(root);
+       btrfs_close_all_devices();
+       return ret;
 }
index 01b3603..fc3812c 100644 (file)
@@ -216,5 +216,6 @@ int main(int argc, char **argv)
 out:
        btrfs_find_root_free(&result);
        close_ctree(root);
+       btrfs_close_all_devices();
        return ret;
 }
index d9fa6b2..0161b5c 100644 (file)
@@ -359,5 +359,6 @@ close:
        close_ctree(root);
        if (ret < 0)
                ret = 1;
+       btrfs_close_all_devices();
        return ret;
 }
index b790f3e..bd44978 100644 (file)
@@ -23,6 +23,7 @@
 #include <sys/stat.h>
 #include "kerncompat.h"
 #include "ctree.h"
+#include "volumes.h"
 #include "disk-io.h"
 #include "print-tree.h"
 #include "transaction.h"
@@ -101,5 +102,6 @@ int main(int ac, char **av)
         */
        printf("using SB copy %llu, bytenr %llu\n", (unsigned long long)num,
               (unsigned long long)bytenr);
+       btrfs_close_all_devices();
        return ret;
 }
index c248ee6..0907aa9 100644 (file)
@@ -548,6 +548,7 @@ int main(int argc, char *argv[])
        }
 out:
        close_ctree(root);
+       btrfs_close_all_devices();
 
        return ret;
 }