Skip to content

Commit e72cb5d

Browse files
zhaoleiddkdave
authored andcommitted
btrfs-progs: Add all missing btrfs_close_all_devices to standalone tools
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>
1 parent da34dbd commit e72cb5d

6 files changed

+10
-1
lines changed

btrfs-calc-size.c

+1
Original file line numberDiff line numberDiff line change
@@ -508,5 +508,6 @@ int main(int argc, char **argv)
508508
out:
509509
close_ctree(root);
510510
free(roots);
511+
btrfs_close_all_devices();
511512
return ret;
512513
}

btrfs-debug-tree.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "disk-io.h"
2929
#include "print-tree.h"
3030
#include "transaction.h"
31+
#include "volumes.h"
3132
#include "utils.h"
3233

3334
static int print_usage(int ret)
@@ -428,5 +429,7 @@ int main(int ac, char **av)
428429
printf("uuid %s\n", uuidbuf);
429430
printf("%s\n", PACKAGE_STRING);
430431
close_root:
431-
return close_ctree(root);
432+
ret = close_ctree(root);
433+
btrfs_close_all_devices();
434+
return ret;
432435
}

btrfs-find-root.c

+1
Original file line numberDiff line numberDiff line change
@@ -216,5 +216,6 @@ int main(int argc, char **argv)
216216
out:
217217
btrfs_find_root_free(&result);
218218
close_ctree(root);
219+
btrfs_close_all_devices();
219220
return ret;
220221
}

btrfs-map-logical.c

+1
Original file line numberDiff line numberDiff line change
@@ -359,5 +359,6 @@ int main(int ac, char **av)
359359
close_ctree(root);
360360
if (ret < 0)
361361
ret = 1;
362+
btrfs_close_all_devices();
362363
return ret;
363364
}

btrfs-select-super.c

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <sys/stat.h>
2424
#include "kerncompat.h"
2525
#include "ctree.h"
26+
#include "volumes.h"
2627
#include "disk-io.h"
2728
#include "print-tree.h"
2829
#include "transaction.h"
@@ -101,5 +102,6 @@ int main(int ac, char **av)
101102
*/
102103
printf("using SB copy %llu, bytenr %llu\n", (unsigned long long)num,
103104
(unsigned long long)bytenr);
105+
btrfs_close_all_devices();
104106
return ret;
105107
}

btrfstune.c

+1
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,7 @@ int main(int argc, char *argv[])
548548
}
549549
out:
550550
close_ctree(root);
551+
btrfs_close_all_devices();
551552

552553
return ret;
553554
}

0 commit comments

Comments
 (0)