diff options
author | Josef Bacik <josef@toxicpanda.com> | 2020-01-24 09:32:33 -0500 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2020-03-23 17:01:28 +0100 |
commit | 3ca35e839e949811c7e35b7ef786de225a1c5008 (patch) | |
tree | 1f1c95838979694b8ef11fb4186021fee0fc021c /fs/btrfs/ioctl.c | |
parent | fc92f79856aaf4edb51ef8ca7650747df34b6dd6 (diff) |
btrfs: hold a ref on the root in search_ioctl
We lookup a arbitrary fs root, we need to hold a ref on that root. If
we're using our own inodes root then grab a ref on that as well to make
the cleanup easier.
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 'fs/btrfs/ioctl.c')
-rw-r--r-- | fs/btrfs/ioctl.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 0e524f3eaa9f..b173bb6915d9 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -2180,7 +2180,7 @@ static noinline int search_ioctl(struct inode *inode, if (sk->tree_id == 0) { /* search the root of the inode that was passed */ - root = BTRFS_I(inode)->root; + root = btrfs_grab_fs_root(BTRFS_I(inode)->root); } else { key.objectid = sk->tree_id; key.type = BTRFS_ROOT_ITEM_KEY; @@ -2190,6 +2190,10 @@ static noinline int search_ioctl(struct inode *inode, btrfs_free_path(path); return PTR_ERR(root); } + if (!btrfs_grab_fs_root(root)) { + btrfs_free_path(path); + return -ENOENT; + } } key.objectid = sk->min_objectid; @@ -2214,6 +2218,7 @@ static noinline int search_ioctl(struct inode *inode, ret = 0; err: sk->nr_items = num_found; + btrfs_put_fs_root(root); btrfs_free_path(path); return ret; } |