net/socket: convert sock_map_fd() to FD_ADD()

Link: https://patch.msgid.link/20251123-work-fd-prepare-v4-30-b6efa1706cfd@kernel.org
Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
Christian Brauner 2025-11-23 17:33:48 +01:00
parent 0d52d06a19
commit 245f0d1c62
No known key found for this signature in database
GPG Key ID: 91C61BC06578DCA2
1 changed files with 5 additions and 14 deletions

View File

@ -503,23 +503,14 @@ EXPORT_SYMBOL(sock_alloc_file);
static int sock_map_fd(struct socket *sock, int flags) static int sock_map_fd(struct socket *sock, int flags)
{ {
struct file *newfile; int fd;
int fd = get_unused_fd_flags(flags);
if (unlikely(fd < 0)) { fd = FD_ADD(flags, sock_alloc_file(sock, flags, NULL));
if (fd < 0)
sock_release(sock); sock_release(sock);
return fd; return fd;
} }
newfile = sock_alloc_file(sock, flags, NULL);
if (!IS_ERR(newfile)) {
fd_install(fd, newfile);
return fd;
}
put_unused_fd(fd);
return PTR_ERR(newfile);
}
/** /**
* sock_from_file - Return the &socket bounded to @file. * sock_from_file - Return the &socket bounded to @file.
* @file: file * @file: file