css_set_fork(): switch to CLASS(fd_raw, ...)

reference acquired there by fget_raw() is not stashed anywhere -
we could as well borrow instead.

Reviewed-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
Al Viro 2024-06-02 15:03:20 -04:00
parent 7133dd5ac6
commit 457a654939

View File

@ -6476,7 +6476,6 @@ static int cgroup_css_set_fork(struct kernel_clone_args *kargs)
struct cgroup *dst_cgrp = NULL; struct cgroup *dst_cgrp = NULL;
struct css_set *cset; struct css_set *cset;
struct super_block *sb; struct super_block *sb;
struct file *f;
if (kargs->flags & CLONE_INTO_CGROUP) if (kargs->flags & CLONE_INTO_CGROUP)
cgroup_lock(); cgroup_lock();
@ -6493,14 +6492,14 @@ static int cgroup_css_set_fork(struct kernel_clone_args *kargs)
return 0; return 0;
} }
f = fget_raw(kargs->cgroup); CLASS(fd_raw, f)(kargs->cgroup);
if (!f) { if (fd_empty(f)) {
ret = -EBADF; ret = -EBADF;
goto err; goto err;
} }
sb = f->f_path.dentry->d_sb; sb = fd_file(f)->f_path.dentry->d_sb;
dst_cgrp = cgroup_get_from_file(f); dst_cgrp = cgroup_get_from_file(fd_file(f));
if (IS_ERR(dst_cgrp)) { if (IS_ERR(dst_cgrp)) {
ret = PTR_ERR(dst_cgrp); ret = PTR_ERR(dst_cgrp);
dst_cgrp = NULL; dst_cgrp = NULL;
@ -6548,15 +6547,12 @@ static int cgroup_css_set_fork(struct kernel_clone_args *kargs)
} }
put_css_set(cset); put_css_set(cset);
fput(f);
kargs->cgrp = dst_cgrp; kargs->cgrp = dst_cgrp;
return ret; return ret;
err: err:
cgroup_threadgroup_change_end(current); cgroup_threadgroup_change_end(current);
cgroup_unlock(); cgroup_unlock();
if (f)
fput(f);
if (dst_cgrp) if (dst_cgrp)
cgroup_put(dst_cgrp); cgroup_put(dst_cgrp);
put_css_set(cset); put_css_set(cset);