file: convert replace_fd() to FD_PREPARE()

Link: https://patch.msgid.link/20251123-work-fd-prepare-v4-44-b6efa1706cfd@kernel.org
Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
Christian Brauner 2025-11-23 17:34:02 +01:00
parent 5f3ea1c201
commit 99d4f12f17
No known key found for this signature in database
GPG Key ID: 91C61BC06578DCA2

View File

@ -1357,28 +1357,25 @@ int replace_fd(unsigned fd, struct file *file, unsigned flags)
*/
int receive_fd(struct file *file, int __user *ufd, unsigned int o_flags)
{
int new_fd;
int error;
error = security_file_receive(file);
if (error)
return error;
new_fd = get_unused_fd_flags(o_flags);
if (new_fd < 0)
return new_fd;
FD_PREPARE(fdf, o_flags, file);
if (fdf.err)
return fdf.err;
get_file(file);
if (ufd) {
error = put_user(new_fd, ufd);
if (error) {
put_unused_fd(new_fd);
error = put_user(fd_prepare_fd(fdf), ufd);
if (error)
return error;
}
}
fd_install(new_fd, get_file(file));
__receive_sock(file);
return new_fd;
__receive_sock(fd_prepare_file(fdf));
return fd_publish(fdf);
}
EXPORT_SYMBOL_GPL(receive_fd);