]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
btrfs: fix root leak if its reloc root is unexpected in merge_reloc_roots()
authorFilipe Manana <fdmanana@suse.com>
Thu, 11 Jun 2026 14:16:21 +0000 (15:16 +0100)
committerDavid Sterba <dsterba@suse.com>
Mon, 29 Jun 2026 23:59:13 +0000 (01:59 +0200)
If we have an unexpected reloc_root for our root, we jump to the out label
but never drop the reference we obtained for root, resulting in a leak.
Add a missing btrfs_put_root() call.

Fixes: 24213fa46c70 ("btrfs: do proper error handling in merge_reloc_roots")
Reviewed-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/relocation.c

index fb85bc8b345c798e3f61981ccc0b1b38672a4acd..9447d009a9a0e98ea02e4186fe58faa44d1f5e83 100644 (file)
@@ -1912,6 +1912,7 @@ again:
                                 * corruption, e.g. bad reloc tree key offset.
                                 */
                                ret = -EINVAL;
+                               btrfs_put_root(root);
                                goto out;
                        }
                        ret = merge_reloc_root(rc, root);