mirror of https://github.com/torvalds/linux.git
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:
parent
0d52d06a19
commit
245f0d1c62
17
net/socket.c
17
net/socket.c
|
|
@ -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
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue