From 0c7136f8e00078116662ea777163545a04eeb538 Mon Sep 17 00:00:00 2001 From: Josef Bacik Date: Fri, 15 Mar 2013 17:13:08 -0400 Subject: [PATCH] Btrfs-progs: fix segfault when using tools fs with tree log We just free the log root after we set it up when we open a ctree in the tools. This isn't nice, it makes double free's and leaks eb's, makes segfaults with btrfs-image. So fix this to be correct, and fix the cleanup if the buffer is not uptodate. With this fix I no longer segfault trying to do btrfs-image on a file system with a log tree. Thanks, Signed-off-by: Josef Bacik --- disk-io.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/disk-io.c b/disk-io.c index a9fd374..6ef35bb 100644 --- a/disk-io.c +++ b/disk-io.c @@ -660,11 +660,12 @@ static int find_and_setup_log_root(struct btrfs_root *tree_root, fs_info->log_root_tree = log_root; if (!extent_buffer_uptodate(log_root->node)) { + free_extent_buffer(log_root->node); free(log_root); + fs_info->log_root_tree = NULL; return -EIO; } - free(log_root); return 0; } -- 2.7.4