]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
Fix error returns in sys_socketpair()
authorDavid Miller <davem@davemloft.net>
Tue, 13 Nov 2007 08:02:56 +0000 (00:02 -0800)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 16 Nov 2007 16:27:37 +0000 (08:27 -0800)
patch bf3c23d171e35e6e168074a1514b0acd59cfd81a in mainline.

[NET]: Fix error reporting in sys_socketpair().

If either of the two sock_alloc_fd() calls fail, we
forget to update 'err' and thus we'll erroneously
return zero in these cases.

Based upon a report and patch from Rich Paul, and
commentary from Chuck Ebbert.

Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
net/socket.c

index a0575243ef7abbaa76ba237c71e924fe10f7ea18..8e5be7477c02ce9f32f8771583f226f5bc19deeb 100644 (file)
@@ -1245,11 +1245,14 @@ asmlinkage long sys_socketpair(int family, int type, int protocol,
                goto out_release_both;
 
        fd1 = sock_alloc_fd(&newfile1);
-       if (unlikely(fd1 < 0))
+       if (unlikely(fd1 < 0)) {
+               err = fd1;
                goto out_release_both;
+       }
 
        fd2 = sock_alloc_fd(&newfile2);
        if (unlikely(fd2 < 0)) {
+               err = fd2;
                put_filp(newfile1);
                put_unused_fd(fd1);
                goto out_release_both;