1 From 6bdf131fac2336adb1a628f992ba32384f653a55 Mon Sep 17 00:00:00 2001
2 From: Josef Bacik <jbacik@fb.com>
3 Date: Fri, 2 Sep 2016 15:25:43 -0400
4 Subject: Btrfs: don't leak reloc root nodes on error
6 From: Josef Bacik <jbacik@fb.com>
8 commit 6bdf131fac2336adb1a628f992ba32384f653a55 upstream.
10 We don't track the reloc roots in any sort of normal way, so the only way the
11 root/commit_root nodes get free'd is if the relocation finishes successfully and
12 the reloc root is deleted. Fix this by free'ing them in free_reloc_roots.
15 Signed-off-by: Josef Bacik <jbacik@fb.com>
16 Signed-off-by: David Sterba <dsterba@suse.com>
17 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
20 fs/btrfs/relocation.c | 4 ++++
21 1 file changed, 4 insertions(+)
23 --- a/fs/btrfs/relocation.c
24 +++ b/fs/btrfs/relocation.c
25 @@ -2366,6 +2366,10 @@ void free_reloc_roots(struct list_head *
26 while (!list_empty(list)) {
27 reloc_root = list_entry(list->next, struct btrfs_root,
29 + free_extent_buffer(reloc_root->node);
30 + free_extent_buffer(reloc_root->commit_root);
31 + reloc_root->node = NULL;
32 + reloc_root->commit_root = NULL;
33 __del_reloc_root(reloc_root);