Skip to content

Commit

Permalink
build_mount_idmapped(): switch to fdget()
Browse files Browse the repository at this point in the history
Reviewed-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
  • Loading branch information
Al Viro committed Apr 21, 2023
1 parent 38e1240 commit 96e85e9
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions fs/namespace.c
Original file line number Diff line number Diff line change
Expand Up @@ -4197,7 +4197,7 @@ static int build_mount_idmapped(const struct mount_attr *attr, size_t usize,
int err = 0;
struct ns_common *ns;
struct user_namespace *mnt_userns;
struct file *file;
struct fd f;

if (!((attr->attr_set | attr->attr_clr) & MOUNT_ATTR_IDMAP))
return 0;
Expand All @@ -4213,16 +4213,16 @@ static int build_mount_idmapped(const struct mount_attr *attr, size_t usize,
if (attr->userns_fd > INT_MAX)
return -EINVAL;

file = fget(attr->userns_fd);
if (!file)
f = fdget(attr->userns_fd);
if (!f.file)
return -EBADF;

if (!proc_ns_file(file)) {
if (!proc_ns_file(f.file)) {
err = -EINVAL;
goto out_fput;
}

ns = get_proc_ns(file_inode(file));
ns = get_proc_ns(file_inode(f.file));
if (ns->ops->type != CLONE_NEWUSER) {
err = -EINVAL;
goto out_fput;
Expand Down Expand Up @@ -4251,7 +4251,7 @@ static int build_mount_idmapped(const struct mount_attr *attr, size_t usize,
kattr->mnt_userns = get_user_ns(mnt_userns);

out_fput:
fput(file);
fdput(f);
return err;
}

Expand Down

0 comments on commit 96e85e9

Please sign in to comment.