mirror of https://github.com/torvalds/linux.git
net/kcm: convert kcm_ioctl() to FD_PREPARE()
Link: https://patch.msgid.link/20251123-work-fd-prepare-v4-28-b6efa1706cfd@kernel.org Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
parent
fe67b063f6
commit
0d52d06a19
|
|
@ -1560,24 +1560,16 @@ static int kcm_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
|
||||||
}
|
}
|
||||||
case SIOCKCMCLONE: {
|
case SIOCKCMCLONE: {
|
||||||
struct kcm_clone info;
|
struct kcm_clone info;
|
||||||
struct file *file;
|
|
||||||
|
|
||||||
info.fd = get_unused_fd_flags(0);
|
FD_PREPARE(fdf, 0, kcm_clone(sock));
|
||||||
if (unlikely(info.fd < 0))
|
if (fdf.err)
|
||||||
return info.fd;
|
return fdf.err;
|
||||||
|
|
||||||
file = kcm_clone(sock);
|
info.fd = fd_prepare_fd(fdf);
|
||||||
if (IS_ERR(file)) {
|
if (copy_to_user((void __user *)arg, &info, sizeof(info)))
|
||||||
put_unused_fd(info.fd);
|
|
||||||
return PTR_ERR(file);
|
|
||||||
}
|
|
||||||
if (copy_to_user((void __user *)arg, &info,
|
|
||||||
sizeof(info))) {
|
|
||||||
put_unused_fd(info.fd);
|
|
||||||
fput(file);
|
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
}
|
|
||||||
fd_install(info.fd, file);
|
fd_publish(fdf);
|
||||||
err = 0;
|
err = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue