Commit 7bfdcf7f authored by Liu Bo's avatar Liu Bo Committed by Chris Mason
Browse files

Btrfs: fix memory leak when cloning root's node

After cloning root's node, we forgot to dec the src's ref
which can lead to a memory leak.
Signed-off-by: default avatarLiu Bo <>
Signed-off-by: default avatarChris Mason <>
parent c657c3ef
......@@ -1241,6 +1241,7 @@ get_old_root(struct btrfs_root *root, u64 time_seq)
struct tree_mod_elem *tm;
struct extent_buffer *eb;
struct extent_buffer *old;
struct tree_mod_root *old_root = NULL;
u64 old_generation = 0;
u64 logical;
......@@ -1264,13 +1265,14 @@ get_old_root(struct btrfs_root *root, u64 time_seq)
blocksize = btrfs_level_size(root, old_root->level);
eb = read_tree_block(root, logical, blocksize, 0);
if (!eb) {
old = read_tree_block(root, logical, blocksize, 0);
if (!old) {
pr_warn("btrfs: failed to read tree block %llu from get_old_root\n",
} else {
eb = btrfs_clone_extent_buffer(eb);
eb = btrfs_clone_extent_buffer(old);
} else if (old_root) {
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment