diff options
Diffstat (limited to 'net/socket.c')
-rw-r--r-- | net/socket.c | 31 |
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, | |||
1396 | goto out_release_both; | 1396 | goto out_release_both; |
1397 | } | 1397 | } |
1398 | 1398 | ||
1399 | fd2 = sock_alloc_fd(&newfile2, flags & O_CLOEXEC); | 1399 | err = sock_attach_fd(sock1, newfile1, flags & O_NONBLOCK); |
1400 | if (unlikely(fd2 < 0)) { | 1400 | if (unlikely(err < 0)) { |
1401 | err = fd2; | ||
1402 | put_filp(newfile1); | 1401 | put_filp(newfile1); |
1403 | put_unused_fd(fd1); | 1402 | put_unused_fd(fd1); |
1404 | goto out_release_both; | 1403 | goto out_release_both; |
1405 | } | 1404 | } |
1406 | 1405 | ||
1407 | err = sock_attach_fd(sock1, newfile1, flags & O_NONBLOCK); | 1406 | fd2 = sock_alloc_fd(&newfile2, flags & O_CLOEXEC); |
1408 | if (unlikely(err < 0)) { | 1407 | if (unlikely(fd2 < 0)) { |
1409 | goto out_fd2; | 1408 | err = fd2; |
1409 | fput(newfile1); | ||
1410 | put_unused_fd(fd1); | ||
1411 | sock_release(sock2); | ||
1412 | goto out; | ||
1410 | } | 1413 | } |
1411 | 1414 | ||
1412 | err = sock_attach_fd(sock2, newfile2, flags & O_NONBLOCK); | 1415 | err = sock_attach_fd(sock2, newfile2, flags & O_NONBLOCK); |
1413 | if (unlikely(err < 0)) { | 1416 | if (unlikely(err < 0)) { |
1417 | put_filp(newfile2); | ||
1418 | put_unused_fd(fd2); | ||
1414 | fput(newfile1); | 1419 | fput(newfile1); |
1415 | goto out_fd1; | 1420 | put_unused_fd(fd1); |
1421 | sock_release(sock2); | ||
1422 | goto out; | ||
1416 | } | 1423 | } |
1417 | 1424 | ||
1418 | audit_fd_pair(fd1, fd2); | 1425 | audit_fd_pair(fd1, fd2); |
@@ -1438,16 +1445,6 @@ out_release_1: | |||
1438 | sock_release(sock1); | 1445 | sock_release(sock1); |
1439 | out: | 1446 | out: |
1440 | return err; | 1447 | return err; |
1441 | |||
1442 | out_fd2: | ||
1443 | put_filp(newfile1); | ||
1444 | sock_release(sock1); | ||
1445 | out_fd1: | ||
1446 | put_filp(newfile2); | ||
1447 | sock_release(sock2); | ||
1448 | put_unused_fd(fd1); | ||
1449 | put_unused_fd(fd2); | ||
1450 | goto out; | ||
1451 | } | 1448 | } |
1452 | 1449 | ||
1453 | /* | 1450 | /* |