summaryrefslogtreecommitdiffstats
path: root/net/socket.c
diff options
context:
space:
mode:
authorLinus Torvalds2018-01-11 02:55:42 +0100
committerLinus Torvalds2018-01-11 02:55:42 +0100
commitcbd0a6a2cc4327681edc61f6f47f47e276ea81d6 (patch)
treefd31d524726517b0f3f1a012bff2c4a62dd8e5a9 /net/socket.c
parentMerge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net (diff)
parentFix a leak in socket(2) when we fail to allocate a file descriptor. (diff)
downloadkernel-qcow2-linux-cbd0a6a2cc4327681edc61f6f47f47e276ea81d6.tar.gz
kernel-qcow2-linux-cbd0a6a2cc4327681edc61f6f47f47e276ea81d6.tar.xz
kernel-qcow2-linux-cbd0a6a2cc4327681edc61f6f47f47e276ea81d6.zip
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull vfs regression fix from Al Viro/ Fix a leak in socket() introduced by commit 8e1611e23579 ("make sock_alloc_file() do sock_release() on failures"). * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: Fix a leak in socket(2) when we fail to allocate a file descriptor.
Diffstat (limited to 'net/socket.c')
-rw-r--r--net/socket.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/net/socket.c b/net/socket.c
index 78acd6ce74c7..6f05d5c4bf30 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -436,8 +436,10 @@ static int sock_map_fd(struct socket *sock, int flags)
{
struct file *newfile;
int fd = get_unused_fd_flags(flags);
- if (unlikely(fd < 0))
+ if (unlikely(fd < 0)) {
+ sock_release(sock);
return fd;
+ }
newfile = sock_alloc_file(sock, flags, NULL);
if (likely(!IS_ERR(newfile))) {