mirror of https://github.com/torvalds/linux.git
Revert "net/socket: convert sock_map_fd() to FD_ADD()"
This reverts commit 245f0d1c62.
When allocating a file sock_alloc_file() consumes the socket reference
unconditionally which isn't correctly handled in the conversion. This
can be fixed by massaging this appropriately but this is best left for
next cycle.
Reported-by: Xin Long <lucien.xin@gmail.com>
Link: https://lore.kernel.org/CADvbK_ewub4ZZK-tZg8GBQbDFHWhd9a48C+AFXZ93pMsssCrUg@mail.gmail.com
Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
parent
b6cb3ccef6
commit
afb9917d9b
19
net/socket.c
19
net/socket.c
|
|
@ -503,12 +503,21 @@ EXPORT_SYMBOL(sock_alloc_file);
|
|||
|
||||
static int sock_map_fd(struct socket *sock, int flags)
|
||||
{
|
||||
int fd;
|
||||
|
||||
fd = FD_ADD(flags, sock_alloc_file(sock, flags, NULL));
|
||||
if (fd < 0)
|
||||
struct file *newfile;
|
||||
int fd = get_unused_fd_flags(flags);
|
||||
if (unlikely(fd < 0)) {
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue