From: Vlad Yasevich Date: Fri, 21 Jul 2006 21:48:26 +0000 (-0700) Subject: [SCTP]: Unhash the endpoint in sctp_endpoint_free(). X-Git-Tag: v2.6.18-rc3~59^2~14 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cfdeef3282705a4b872d3559c4e7d2561251363c;p=linux-2.6 [SCTP]: Unhash the endpoint in sctp_endpoint_free(). This prevents a race between the close of a socket and receive of an incoming packet. Signed-off-by: Vlad Yasevich Signed-off-by: Sridhar Samudrala Signed-off-by: David S. Miller --- diff --git a/net/sctp/endpointola.c b/net/sctp/endpointola.c index 67bd53070e..ffda1d6805 100644 --- a/net/sctp/endpointola.c +++ b/net/sctp/endpointola.c @@ -158,6 +158,12 @@ void sctp_endpoint_add_asoc(struct sctp_endpoint *ep, void sctp_endpoint_free(struct sctp_endpoint *ep) { ep->base.dead = 1; + + ep->base.sk->sk_state = SCTP_SS_CLOSED; + + /* Unlink this endpoint, so we can't find it again! */ + sctp_unhash_endpoint(ep); + sctp_endpoint_put(ep); } @@ -166,11 +172,6 @@ static void sctp_endpoint_destroy(struct sctp_endpoint *ep) { SCTP_ASSERT(ep->base.dead, "Endpoint is not dead", return); - ep->base.sk->sk_state = SCTP_SS_CLOSED; - - /* Unlink this endpoint, so we can't find it again! */ - sctp_unhash_endpoint(ep); - /* Free up the HMAC transform. */ sctp_crypto_free_tfm(sctp_sk(ep->base.sk)->hmac);