btrfs: fix anon_dev leak in create_subvol()
authorOmar Sandoval <osandov@fb.com>
Thu, 10 Mar 2022 01:31:33 +0000 (17:31 -0800)
committerDavid Sterba <dsterba@suse.com>
Mon, 16 May 2022 15:03:06 +0000 (17:03 +0200)
commit2256e901f5bddc56e24089c96f27b77da932dfcc
treec2465ec67775d7955c2307aff4ea96bc473014fb
parentc16218714307849a949f83cbad00b1b4ec166bb6
btrfs: fix anon_dev leak in create_subvol()

When btrfs_qgroup_inherit(), btrfs_alloc_tree_block, or
btrfs_insert_root() fail in create_subvol(), we return without freeing
anon_dev. Reorganize the error handling in create_subvol() to fix this.

Reviewed-by: Sweet Tea Dorminy <sweettea-kernel@dorminy.me>
Signed-off-by: Omar Sandoval <osandov@fb.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/ioctl.c