summaryrefslogtreecommitdiffstats
path: root/fs/btrfs/ioctl.c
diff options
context:
space:
mode:
authorJosef Bacik <josef@toxicpanda.com>2020-01-24 15:32:34 +0100
committerDavid Sterba <dsterba@suse.com>2020-03-23 17:01:28 +0100
commit88234012beaaf677dc6d3e685d270acc1bb56a03 (patch)
treef9942ac3800577159bc0ee5a6627fba6aabf1910 /fs/btrfs/ioctl.c
parentbtrfs: hold a ref on the root in search_ioctl (diff)
downloadlinux-88234012beaaf677dc6d3e685d270acc1bb56a03.tar.xz
linux-88234012beaaf677dc6d3e685d270acc1bb56a03.zip
btrfs: hold a ref on the root in btrfs_search_path_in_tree
We look up an arbitrary fs root, we need to hold a ref on it while we're doing our search. Signed-off-by: Josef Bacik <josef@toxicpanda.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to '')
-rw-r--r--fs/btrfs/ioctl.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index b173bb6915d9..9c8a9944f848 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -2328,6 +2328,12 @@ static noinline int btrfs_search_path_in_tree(struct btrfs_fs_info *info,
root = btrfs_get_fs_root(info, &key, true);
if (IS_ERR(root)) {
ret = PTR_ERR(root);
+ root = NULL;
+ goto out;
+ }
+ if (!btrfs_grab_fs_root(root)) {
+ ret = -ENOENT;
+ root = NULL;
goto out;
}
@@ -2378,6 +2384,7 @@ static noinline int btrfs_search_path_in_tree(struct btrfs_fs_info *info,
name[total_len] = '\0';
ret = 0;
out:
+ btrfs_put_fs_root(root);
btrfs_free_path(path);
return ret;
}