Skip to content

Commit bdf70b9

Browse files
josefbacikkdave
authored andcommitted
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>
1 parent 9326f76 commit bdf70b9

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

‎fs/btrfs/export.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,17 @@ static struct dentry *btrfs_get_dentry(struct super_block *sb, u64 objectid,
8282
err = PTR_ERR(root);
8383
goto fail;
8484
}
85+
if (!btrfs_grab_fs_root(root)) {
86+
err = -ENOENT;
87+
goto fail;
88+
}
8589

8690
key.objectid = objectid;
8791
key.type = BTRFS_INODE_ITEM_KEY;
8892
key.offset = 0;
8993

9094
inode = btrfs_iget(sb, &key, root);
95+
btrfs_put_fs_root(root);
9196
if (IS_ERR(inode)) {
9297
err = PTR_ERR(inode);
9398
goto fail;

0 commit comments

Comments
 (0)