diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2018-01-10 20:55:42 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2018-01-10 20:55:42 -0500 |
commit | cbd0a6a2cc4327681edc61f6f47f47e276ea81d6 (patch) | |
tree | fd31d524726517b0f3f1a012bff2c4a62dd8e5a9 | |
parent | 64fce444f126b9d26574221330d9599fe998944e (diff) | |
parent | ce4bb04cae8924792ed92f4af2793b77fc986f0e (diff) |
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.
-rw-r--r-- | net/socket.c | 4 |
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) | |||
436 | { | 436 | { |
437 | struct file *newfile; | 437 | struct file *newfile; |
438 | int fd = get_unused_fd_flags(flags); | 438 | int fd = get_unused_fd_flags(flags); |
439 | if (unlikely(fd < 0)) | 439 | if (unlikely(fd < 0)) { |
440 | sock_release(sock); | ||
440 | return fd; | 441 | return fd; |
442 | } | ||
441 | 443 | ||
442 | newfile = sock_alloc_file(sock, flags, NULL); | 444 | newfile = sock_alloc_file(sock, flags, NULL); |
443 | if (likely(!IS_ERR(newfile))) { | 445 | if (likely(!IS_ERR(newfile))) { |