diff mbox

[v2] Btrfs: fix panic in balance due to EIO

Message ID 1468344577-8684-1-git-send-email-bo.li.liu@oracle.com (mailing list archive)
State Accepted
Headers show

Commit Message

Liu Bo July 12, 2016, 5:29 p.m. UTC
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 <bo.li.liu@oracle.com>
---
v2: Set node to NULL if we know it'll be freed.

 fs/btrfs/relocation.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Chris Mason July 12, 2016, 6:01 p.m. UTC | #1
On 07/12/2016 01:29 PM, Liu Bo wrote:
> 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 <bo.li.liu@oracle.com>

Signed-off-by: Chris Mason <clm@fb.com>

-chris
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index 9732919..535314a 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -1171,8 +1171,12 @@  out:
 			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);