diff options
author | Josef Bacik <josef@toxicpanda.com> | 2020-01-24 09:32:31 -0500 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2020-02-10 14:40:30 +0100 |
commit | cb59b067893eb52ff698fd8e4d41bfafc0626d12 (patch) | |
tree | 571bc63c4ae6752d550bd69e52f11cbdf3375ed7 | |
parent | 5f526def3313a6f2536b1fb27f721f6f67288496 (diff) | |
download | btrfs-next-cb59b067893eb52ff698fd8e4d41bfafc0626d12.tar.gz |
btrfs: hold a ref on the root in fixup_tree_root_location
Looking up the inode from an arbitrary tree means we need to hold a ref
on that root.
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r-- | fs/btrfs/inode.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 5c897d8c950687..3fc69ec699c9ea 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -5150,6 +5150,10 @@ static int fixup_tree_root_location(struct btrfs_fs_info *fs_info, err = PTR_ERR(new_root); goto out; } + if (!btrfs_grab_fs_root(new_root)) { + err = -ENOENT; + goto out; + } *sub_root = new_root; location->objectid = btrfs_root_dirid(&new_root->root_item); @@ -5392,6 +5396,8 @@ struct inode *btrfs_lookup_dentry(struct inode *dir, struct dentry *dentry) } else { inode = btrfs_iget(dir->i_sb, &location, sub_root); } + if (root != sub_root) + btrfs_put_fs_root(sub_root); srcu_read_unlock(&fs_info->subvol_srcu, index); if (!IS_ERR(inode) && root != sub_root) { |