From: Josef Bacik Date: Wed, 4 Mar 2020 16:18:23 +0000 (-0500) Subject: btrfs: drop block from cache on error in relocation X-Git-Tag: v4.9.220~85 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c7b7daf956babcde75c4fddd99244d20f25ddedc;p=platform%2Fkernel%2Flinux-amlogic.git btrfs: drop block from cache on error in relocation commit 8e19c9732ad1d127b5575a10f4fbcacf740500ff upstream. If we have an error while building the backref tree in relocation we'll process all the pending edges and then free the node. However if we integrated some edges into the cache we'll lose our link to those edges by simply freeing this node, which means we'll leak memory and references to any roots that we've found. Instead we need to use remove_backref_node(), which walks through all of the edges that are still linked to this node and free's them up and drops any root references we may be holding. CC: stable@vger.kernel.org # 4.9+ Reviewed-by: Qu Wenruo Signed-off-by: Josef Bacik Reviewed-by: David Sterba Signed-off-by: David Sterba Signed-off-by: Greg Kroah-Hartman --- diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c index 8d98e8e248b7..1ca2752cc3b4 100644 --- a/fs/btrfs/relocation.c +++ b/fs/btrfs/relocation.c @@ -1185,7 +1185,7 @@ out: free_backref_node(cache, lower); } - free_backref_node(cache, node); + remove_backref_node(cache, node); return ERR_PTR(err); } ASSERT(!node || !node->detached);