]> err.no Git - linux-2.6/commitdiff
[NET]: Fully fix the memory leaks in sys_accept().
authorDavid S. Miller <davem@sunset.davemloft.net>
Sat, 1 Apr 2006 20:48:36 +0000 (12:48 -0800)
committerDavid S. Miller <davem@sunset.davemloft.net>
Sat, 1 Apr 2006 20:48:36 +0000 (12:48 -0800)
Andi Kleen was right, fput() on sock->file will end up calling
sock_release() if necessary.  So here is the rest of his version
of the fix for these leaks.

Signed-off-by: David S. Miller <davem@davemloft.net>
net/socket.c

index bbc80780f45afa84b073aff901640337b4dcfe95..b807f360e02ccc336ad45f606feb92506b21af77 100644 (file)
@@ -1418,7 +1418,8 @@ asmlinkage long sys_accept(int fd, struct sockaddr __user *upeer_sockaddr, int _
        newfd = sock_alloc_fd(&newfile);
        if (unlikely(newfd < 0)) {
                err = newfd;
-               goto out_release;
+               sock_release(newsock);
+               goto out_put;
        }
 
        err = sock_attach_fd(newsock, newfile);
@@ -1457,8 +1458,6 @@ out:
 out_fd:
        fput(newfile);
        put_unused_fd(newfd);
-out_release:
-       sock_release(newsock);
        goto out_put;
 }