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
17
net/socket.c
17
net/socket.c
|
|
@ -503,14 +503,23 @@ 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)
|
||||||
{
|
{
|
||||||
int fd;
|
struct file *newfile;
|
||||||
|
int fd = get_unused_fd_flags(flags);
|
||||||
fd = FD_ADD(flags, sock_alloc_file(sock, flags, NULL));
|
if (unlikely(fd < 0)) {
|
||||||
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