This patch add all missing btrfs_close_all_devices() to standalone tools in btrfs progs, to avoid memory leak.
Signed-off-by: Zhao Lei <zhao...@cn.fujitsu.com> --- btrfs-calc-size.c | 1 + btrfs-debug-tree.c | 5 ++++- btrfs-find-root.c | 1 + btrfs-map-logical.c | 1 + btrfs-select-super.c | 2 ++ btrfstune.c | 1 + 6 files changed, 10 insertions(+), 1 deletion(-) diff --git a/btrfs-calc-size.c b/btrfs-calc-size.c index 7287858..b756693 100644 --- a/btrfs-calc-size.c +++ b/btrfs-calc-size.c @@ -508,5 +508,6 @@ int main(int argc, char **argv) out: close_ctree(root); free(roots); + btrfs_close_all_devices(); return ret; } diff --git a/btrfs-debug-tree.c b/btrfs-debug-tree.c index 7d8e876..8adc39f 100644 --- a/btrfs-debug-tree.c +++ b/btrfs-debug-tree.c @@ -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; } diff --git a/btrfs-find-root.c b/btrfs-find-root.c index 01b3603..fc3812c 100644 --- a/btrfs-find-root.c +++ b/btrfs-find-root.c @@ -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; } diff --git a/btrfs-map-logical.c b/btrfs-map-logical.c index d9fa6b2..0161b5c 100644 --- a/btrfs-map-logical.c +++ b/btrfs-map-logical.c @@ -359,5 +359,6 @@ close: close_ctree(root); if (ret < 0) ret = 1; + btrfs_close_all_devices(); return ret; } diff --git a/btrfs-select-super.c b/btrfs-select-super.c index b790f3e..bd44978 100644 --- a/btrfs-select-super.c +++ b/btrfs-select-super.c @@ -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; } diff --git a/btrfstune.c b/btrfstune.c index c248ee6..0907aa9 100644 --- a/btrfstune.c +++ b/btrfstune.c @@ -548,6 +548,7 @@ int main(int argc, char *argv[]) } out: close_ctree(root); + btrfs_close_all_devices(); return ret; } -- 1.8.5.1 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html