From: Liu Bo Date: Tue, 12 Jul 2016 17:29:37 +0000 (-0700) Subject: Btrfs: fix panic in balance due to EIO X-Git-Tag: v4.8-rc1~38^2~1^2~19 X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=commitdiff_plain;h=0fd8c3dae14fb64947842472940b807ca0781da9;p=linux.git Btrfs: fix panic in balance due to EIO During build_backref_tree(), if we fail to read a btree node, we can eventually run into BUG_ON(cache->nr_nodes) that we put in backref_cache_cleanup(), meaning we have at least one memory leak. This frees the backref_node that we's allocated at the very beginning of build_backref_tree(). Signed-off-by: Liu Bo Signed-off-by: David Sterba --- diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c index 13c9a48c83b0..97cafe7291b8 100644 --- a/fs/btrfs/relocation.c +++ b/fs/btrfs/relocation.c @@ -1171,8 +1171,12 @@ struct backref_node *build_backref_tree(struct reloc_control *rc, lower = list_entry(useless.next, struct backref_node, list); list_del_init(&lower->list); + if (lower == node) + node = NULL; free_backref_node(cache, lower); } + + free_backref_node(cache, node); return ERR_PTR(err); } ASSERT(!node || !node->detached);