summaryrefslogtreecommitdiff
path: root/fs/btrfs/export.c
diff options
context:
space:
mode:
authorJosef Bacik <josef@toxicpanda.com>2020-01-24 09:32:29 -0500
committerDavid Sterba <dsterba@suse.com>2020-03-23 17:01:27 +0100
commitbdf70b9e75f54a04941dc450abe61694e03fead4 (patch)
treedd5acf93b7281ab3e50685ccfb0d333e264f2c46 /fs/btrfs/export.c
parent9326f76f4bc4f4fc624d2f5263386ac879957867 (diff)
btrfs: hold a root ref in btrfs_get_dentry
Looking up the inode we need to search the root, make sure we hold a reference on that root while we're doing the lookup. 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/export.c')
-rw-r--r--fs/btrfs/export.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/fs/btrfs/export.c b/fs/btrfs/export.c
index 08cd8c4a02a5..eba6c6d27bad 100644
--- a/fs/btrfs/export.c
+++ b/fs/btrfs/export.c
@@ -82,12 +82,17 @@ static struct dentry *btrfs_get_dentry(struct super_block *sb, u64 objectid,
err = PTR_ERR(root);
goto fail;
}
+ if (!btrfs_grab_fs_root(root)) {
+ err = -ENOENT;
+ goto fail;
+ }
key.objectid = objectid;
key.type = BTRFS_INODE_ITEM_KEY;
key.offset = 0;
inode = btrfs_iget(sb, &key, root);
+ btrfs_put_fs_root(root);
if (IS_ERR(inode)) {
err = PTR_ERR(inode);
goto fail;