summaryrefslogtreecommitdiff
path: root/btrfs-debug-tree.c
diff options
context:
space:
mode:
authorQu Wenruo <quwenruo@cn.fujitsu.com>2015-02-11 09:57:17 +0800
committerDavid Sterba <dsterba@suse.cz>2015-02-11 19:08:43 +0100
commitd09504edb148336893d2a67c4cceb09b640ade14 (patch)
treead1e7048b3e0ba2fce722d2965d9b5c7d5ffbeaf /btrfs-debug-tree.c
parenta1231346d67d8ae0e4aa5dd80818dcbda2336ed9 (diff)
downloadbtrfs-progs-d09504edb148336893d2a67c4cceb09b640ade14.tar.gz
btrfs-progs: Fix 2 extent buffer leak in btrfs-debug-tree
There are 2 known extent buffer leaks: 1) With -t option. -t option will skip other tree roots, but it will read the root node first and then skip it. Where it forgets to free the tree block it read. 2) with -b option. It forgets to free the tree block it read. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
Diffstat (limited to 'btrfs-debug-tree.c')
-rw-r--r--btrfs-debug-tree.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/btrfs-debug-tree.c b/btrfs-debug-tree.c
index ce7a792..610624e 100644
--- a/btrfs-debug-tree.c
+++ b/btrfs-debug-tree.c
@@ -221,6 +221,7 @@ int main(int ac, char **av)
goto close_root;
}
btrfs_print_tree(root, leaf, 0);
+ free_extent_buffer(leaf);
goto close_root;
}
@@ -284,8 +285,10 @@ again:
0);
if (!extent_buffer_uptodate(buf))
goto next;
- if (tree_id && found_key.objectid != tree_id)
+ if (tree_id && found_key.objectid != tree_id) {
+ free_extent_buffer(buf);
goto next;
+ }
switch(found_key.objectid) {
case BTRFS_ROOT_TREE_OBJECTID: