mirror of
https://github.com/torvalds/linux.git
synced 2026-06-01 02:53:36 +02:00
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:
parent
5f3ea1c201
commit
99d4f12f17
19
fs/file.c
19
fs/file.c
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user