]> git.hungrycats.org Git - linux/commitdiff
Btrfs: don't leak reloc root nodes on error
authorJosef Bacik <jbacik@fb.com>
Fri, 2 Sep 2016 19:25:43 +0000 (15:25 -0400)
committerZygo Blaxell <zblaxell@thirteen.furryterror.org>
Sat, 24 Sep 2016 04:03:37 +0000 (00:03 -0400)
We don't track the reloc roots in any sort of normal way, so the only way the
root/commit_root nodes get free'd is if the relocation finishes successfully and
the reloc root is deleted.  Fix this by free'ing them in free_reloc_roots.
Thanks,

Signed-off-by: Josef Bacik <jbacik@fb.com>
Signed-off-by: David Sterba <dsterba@suse.com>
(cherry picked from commit c9a0ee85485015c097fe307f026d34d3e1bfed76)

fs/btrfs/relocation.c

index 2fc8c26f055ad0f03ddec05f8bb61163235759ca..39e25b859808a3f11ab99d4b3ad475f58405f6e5 100644 (file)
@@ -2349,6 +2349,10 @@ void free_reloc_roots(struct list_head *list)
        while (!list_empty(list)) {
                reloc_root = list_entry(list->next, struct btrfs_root,
                                        root_list);
+               free_extent_buffer(reloc_root->node);
+               free_extent_buffer(reloc_root->commit_root);
+               reloc_root->node = NULL;
+               reloc_root->commit_root = NULL;
                __del_reloc_root(reloc_root);
        }
 }