]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blobdiff - net/sctp/endpointola.c
net: sctp: rework debugging framework to use pr_debug and friends
[mirror_ubuntu-artful-kernel.git] / net / sctp / endpointola.c
index 5fbd7bc6bb11077f8af91bf01ea8403c5087c31e..9e3d257de0e0814274cf852ae883835bb4c72eac 100644 (file)
@@ -192,9 +192,10 @@ struct sctp_endpoint *sctp_endpoint_new(struct sock *sk, gfp_t gfp)
        struct sctp_endpoint *ep;
 
        /* Build a local endpoint. */
-       ep = t_new(struct sctp_endpoint, gfp);
+       ep = kzalloc(sizeof(*ep), gfp);
        if (!ep)
                goto fail;
+
        if (!sctp_endpoint_init(ep, sk, gfp))
                goto fail_init;
 
@@ -246,10 +247,12 @@ void sctp_endpoint_free(struct sctp_endpoint *ep)
 /* Final destructor for endpoint.  */
 static void sctp_endpoint_destroy(struct sctp_endpoint *ep)
 {
-       SCTP_ASSERT(ep->base.dead, "Endpoint is not dead", return);
+       struct sock *sk;
 
-       /* Free up the HMAC transform. */
-       crypto_free_hash(sctp_sk(ep->base.sk)->hmac);
+       if (unlikely(!ep->base.dead)) {
+               WARN(1, "Attempt to destroy undead endpoint %p!\n", ep);
+               return;
+       }
 
        /* Free the digest buffer */
        kfree(ep->digest);
@@ -270,13 +273,15 @@ static void sctp_endpoint_destroy(struct sctp_endpoint *ep)
 
        memset(ep->secret_key, 0, sizeof(ep->secret_key));
 
-       /* Remove and free the port */
-       if (sctp_sk(ep->base.sk)->bind_hash)
-               sctp_put_port(ep->base.sk);
-
        /* Give up our hold on the sock. */
-       if (ep->base.sk)
-               sock_put(ep->base.sk);
+       sk = ep->base.sk;
+       if (sk != NULL) {
+               /* Remove and free the port */
+               if (sctp_sk(sk)->bind_hash)
+                       sctp_put_port(sk);
+
+               sock_put(sk);
+       }
 
        kfree(ep);
        SCTP_DBG_OBJCNT_DEC(ep);