]> git.hungrycats.org Git - linux/commitdiff
btrfs: do not leak reloc root if we fail to read the fs root
authorJosef Bacik <josef@toxicpanda.com>
Fri, 22 Nov 2019 18:21:24 +0000 (10:21 -0800)
committerJosef Bacik <josef@toxicpanda.com>
Fri, 6 Dec 2019 16:34:48 +0000 (08:34 -0800)
If we fail to read the fs root corresponding with a reloc root we'll
just break out and free the reloc roots.  But we remove our current
reloc_root from this list higher up, which means we'll leak this
reloc_root.  Fix this by adding ourselves back to the reloc_roots list
so we are properly cleaned up.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
fs/btrfs/relocation.c

index a857fc8271d270ec190981c0db74e6e87a3ea573..c5fcddad1c15009287b93124d8db159374482711 100644 (file)
@@ -4554,6 +4554,7 @@ int btrfs_recover_relocation(struct btrfs_root *root)
                fs_root = read_fs_root(fs_info, reloc_root->root_key.offset);
                if (IS_ERR(fs_root)) {
                        err = PTR_ERR(fs_root);
+                       list_add_tail(&reloc_root->root_list, &reloc_roots);
                        goto out_free;
                }