summaryrefslogtreecommitdiff
path: root/fs/btrfs/extent-tree.c
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2007-03-12 09:03:27 -0400
committerDavid Woodhouse <dwmw2@hera.kernel.org>2007-03-12 09:03:27 -0400
commit83e15a28e046dbb4534dd263d1d3dc867a8994a2 (patch)
treeb6b2c9755520fd1c9993e847c8e7f1ef8be3f3e9 /fs/btrfs/extent-tree.c
parent20524f02260910db1e67bd5335d3854e5e555efc (diff)
downloadlwn-83e15a28e046dbb4534dd263d1d3dc867a8994a2.tar.gz
lwn-83e15a28e046dbb4534dd263d1d3dc867a8994a2.zip
fix leak in btrfs_drop_snapshot
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/extent-tree.c')
-rw-r--r--fs/btrfs/extent-tree.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 6fbaece43ff6..e7b8a70b5e52 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -441,15 +441,15 @@ int walk_down_tree(struct ctree_root *root, struct ctree_path *path, int *level)
}
BUG_ON(ret);
next = read_tree_block(root, blocknr);
- if (path->nodes[*level-1]) {
+ if (path->nodes[*level-1])
tree_block_release(root, path->nodes[*level-1]);
- }
path->nodes[*level-1] = next;
*level = node_level(next->node.header.flags);
path->slots[*level] = 0;
}
out:
ret = free_extent(root, path->nodes[*level]->blocknr, 1);
+ tree_block_release(root, path->nodes[*level]);
path->nodes[*level] = NULL;
*level += 1;
BUG_ON(ret);
@@ -470,6 +470,8 @@ int walk_up_tree(struct ctree_root *root, struct ctree_path *path, int *level)
} else {
ret = free_extent(root,
path->nodes[*level]->blocknr, 1);
+ tree_block_release(root, path->nodes[*level]);
+ path->nodes[*level] = NULL;
*level = i + 1;
BUG_ON(ret);
}
@@ -499,9 +501,10 @@ int btrfs_drop_snapshot(struct ctree_root *root, struct tree_buffer *snap)
if (ret > 0)
break;
}
- for (i = 0; i < orig_level; i++) {
- if (path.nodes[i])
+ for (i = 0; i <= orig_level; i++) {
+ if (path.nodes[i]) {
tree_block_release(root, path.nodes[i]);
+ }
}
return 0;