[NET]: sanitize kernel_accept() error path

If kernel_accept() returns an error, it may pass back a pointer to
freed memory (which the caller should ignore).  Make it pass back NULL
instead for better safety.

Signed-off-by: Tony Battersby <tonyb@cybernetics.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Tony Battersby 2007-10-10 21:09:04 -07:00 committed by David S. Miller
parent 414c66e00e
commit fa8705b00a

View file

@ -2235,6 +2235,7 @@ int kernel_accept(struct socket *sock, struct socket **newsock, int flags)
err = sock->ops->accept(sock, *newsock, flags); err = sock->ops->accept(sock, *newsock, flags);
if (err < 0) { if (err < 0) {
sock_release(*newsock); sock_release(*newsock);
*newsock = NULL;
goto done; goto done;
} }