Adding a btrfs_close_all_devices() after command callback in btrfs.c
can force-close all opened device before program exit, to avoid memory leak
in all btrfs sub-command.
Suggested-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
#include <stdlib.h>
#include <string.h>
#include <stdlib.h>
#include <string.h>
#include "crc32c.h"
#include "commands.h"
#include "utils.h"
#include "crc32c.h"
#include "commands.h"
#include "utils.h"
{
const struct cmd_struct *cmd;
const char *bname;
{
const struct cmd_struct *cmd;
const char *bname;
if ((bname = strrchr(argv[0], '/')) != NULL)
bname++;
if ((bname = strrchr(argv[0], '/')) != NULL)
bname++;
crc32c_optimization_init();
fixup_argv0(argv, cmd->token);
crc32c_optimization_init();
fixup_argv0(argv, cmd->token);
- exit(cmd->fn(argc, argv));
+
+ ret = cmd->fn(argc, argv);
+
+ btrfs_close_all_devices();
+
+ exit(ret);