All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Btrfs-progs: fix segfault when using tools fs with tree log
@ 2013-03-15 21:13 Josef Bacik
  0 siblings, 0 replies; only message in thread
From: Josef Bacik @ 2013-03-15 21:13 UTC (permalink / raw)
  To: linux-btrfs

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 <jbacik@fusionio.com>
---
 disk-io.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/disk-io.c b/disk-io.c
index 5aa9aa3..da7086f 100644
--- a/disk-io.c
+++ b/disk-io.c
@@ -656,11 +656,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;
 }
 
-- 
1.7.7.6


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2013-03-15 21:05 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-15 21:13 [PATCH] Btrfs-progs: fix segfault when using tools fs with tree log Josef Bacik

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.