Re: [PATCH] net: fix kernel_accept() error path

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: James Morris <jmorris@...>
Cc: <netdev@...>, <davem@...>
Date: Thursday, October 4, 2007 - 6:12 pm

James Morris wrote:

Here is an example of what I would consider "reasonable code" that would
fail:

int example()
{
    struct socket *conn_socket = NULL;
    int err;

    ...

    if ((err = kernel_accept(sock, &conn_socket, 0)) < 0)
        goto out_cleanup;

    [do whatever with conn_socket]

 out_cleanup:

    if (conn_socket != NULL)
        sock_release(&conn_socket);

    return err;
}

Without the patch, the double sock_release() will cause a BUG().

Also compare to sock_create_lite(), which sets *res to NULL on error.

Tony

-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] net: fix kernel_accept() error path, Tony Battersby, (Thu Oct 4, 4:20 pm)
Re: [PATCH] net: fix kernel_accept() error path, James Morris, (Thu Oct 4, 5:57 pm)
Re: [PATCH] net: fix kernel_accept() error path, Tony Battersby, (Thu Oct 4, 6:12 pm)
Re: [PATCH] net: fix kernel_accept() error path, David Miller, (Thu Oct 4, 7:55 pm)
Re: [PATCH] net: fix kernel_accept() error path, David Miller, (Thu Oct 4, 6:08 pm)