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:
Christian Brauner 2025-11-23 17:33:46 +01:00
parent fe67b063f6
commit 0d52d06a19
No known key found for this signature in database
GPG Key ID: 91C61BC06578DCA2
1 changed files with 7 additions and 15 deletions

View File

@ -1560,24 +1560,16 @@ static int kcm_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
}
case SIOCKCMCLONE: {
struct kcm_clone info;
struct file *file;
info.fd = get_unused_fd_flags(0);
if (unlikely(info.fd < 0))
return info.fd;
FD_PREPARE(fdf, 0, kcm_clone(sock));
if (fdf.err)
return fdf.err;
file = kcm_clone(sock);
if (IS_ERR(file)) {
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);
info.fd = fd_prepare_fd(fdf);
if (copy_to_user((void __user *)arg, &info, sizeof(info)))
return -EFAULT;
}
fd_install(info.fd, file);
fd_publish(fdf);
err = 0;
break;
}