summaryrefslogtreecommitdiffstats
path: root/net/socket.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2009-08-05 19:29:23 +0400
committerAl Viro <viro@zeniv.linux.org.uk>2009-12-16 12:16:41 -0500
commit198de4d7ac3a0f1351c6377ff657950457ed0038 (patch)
tree0451461b303cc3d4d514acadc09b8dee1a260818 /net/socket.c
parent732741274d0269718ba20c520cf72530bb038641 (diff)
downloadlinux-198de4d7ac3a0f1351c6377ff657950457ed0038.tar.gz
linux-198de4d7ac3a0f1351c6377ff657950457ed0038.tar.bz2
linux-198de4d7ac3a0f1351c6377ff657950457ed0038.zip
reorder alloc_fd/attach_fd in socketpair()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'net/socket.c')
-rw-r--r--net/socket.c31
1 files changed, 14 insertions, 17 deletions
diff --git a/net/socket.c b/net/socket.c
index b94c3dd71015..bf538bea8fbf 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -1396,23 +1396,30 @@ SYSCALL_DEFINE4(socketpair, int, family, int, type, int, protocol,
goto out_release_both;
}
- fd2 = sock_alloc_fd(&newfile2, flags & O_CLOEXEC);
- if (unlikely(fd2 < 0)) {
- err = fd2;
+ err = sock_attach_fd(sock1, newfile1, flags & O_NONBLOCK);
+ if (unlikely(err < 0)) {
put_filp(newfile1);
put_unused_fd(fd1);
goto out_release_both;
}
- err = sock_attach_fd(sock1, newfile1, flags & O_NONBLOCK);
- if (unlikely(err < 0)) {
- goto out_fd2;
+ fd2 = sock_alloc_fd(&newfile2, flags & O_CLOEXEC);
+ if (unlikely(fd2 < 0)) {
+ err = fd2;
+ fput(newfile1);
+ put_unused_fd(fd1);
+ sock_release(sock2);
+ goto out;
}
err = sock_attach_fd(sock2, newfile2, flags & O_NONBLOCK);
if (unlikely(err < 0)) {
+ put_filp(newfile2);
+ put_unused_fd(fd2);
fput(newfile1);
- goto out_fd1;
+ put_unused_fd(fd1);
+ sock_release(sock2);
+ goto out;
}
audit_fd_pair(fd1, fd2);
@@ -1438,16 +1445,6 @@ out_release_1:
sock_release(sock1);
out:
return err;
-
-out_fd2:
- put_filp(newfile1);
- sock_release(sock1);
-out_fd1:
- put_filp(newfile2);
- sock_release(sock2);
- put_unused_fd(fd1);
- put_unused_fd(fd2);
- goto out;
}
/*