mirror of
https://github.com/torvalds/linux.git
synced 2025-12-07 20:06:24 +00:00
net/socket: convert __sys_accept4_file() to FD_ADD()
Link: https://patch.msgid.link/20251123-work-fd-prepare-v4-31-b6efa1706cfd@kernel.org Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
15
net/socket.c
15
net/socket.c
@@ -2003,8 +2003,6 @@ static int __sys_accept4_file(struct file *file, struct sockaddr __user *upeer_s
|
|||||||
int __user *upeer_addrlen, int flags)
|
int __user *upeer_addrlen, int flags)
|
||||||
{
|
{
|
||||||
struct proto_accept_arg arg = { };
|
struct proto_accept_arg arg = { };
|
||||||
struct file *newfile;
|
|
||||||
int newfd;
|
|
||||||
|
|
||||||
if (flags & ~(SOCK_CLOEXEC | SOCK_NONBLOCK))
|
if (flags & ~(SOCK_CLOEXEC | SOCK_NONBLOCK))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
@@ -2012,18 +2010,7 @@ static int __sys_accept4_file(struct file *file, struct sockaddr __user *upeer_s
|
|||||||
if (SOCK_NONBLOCK != O_NONBLOCK && (flags & SOCK_NONBLOCK))
|
if (SOCK_NONBLOCK != O_NONBLOCK && (flags & SOCK_NONBLOCK))
|
||||||
flags = (flags & ~SOCK_NONBLOCK) | O_NONBLOCK;
|
flags = (flags & ~SOCK_NONBLOCK) | O_NONBLOCK;
|
||||||
|
|
||||||
newfd = get_unused_fd_flags(flags);
|
return FD_ADD(flags, do_accept(file, &arg, upeer_sockaddr, upeer_addrlen, flags));
|
||||||
if (unlikely(newfd < 0))
|
|
||||||
return newfd;
|
|
||||||
|
|
||||||
newfile = do_accept(file, &arg, upeer_sockaddr, upeer_addrlen,
|
|
||||||
flags);
|
|
||||||
if (IS_ERR(newfile)) {
|
|
||||||
put_unused_fd(newfd);
|
|
||||||
return PTR_ERR(newfile);
|
|
||||||
}
|
|
||||||
fd_install(newfd, newfile);
|
|
||||||
return newfd;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
Reference in New Issue
Block a user