From: Daniel Borkmann <dborkman@redhat.com>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, linux-sctp@vger.kernel.org
Subject: [PATCH net-next 1/3] net: sctp: let sctp_destroy_sock destroy related members
Date: Fri, 7 Jun 2013 10:35:04 +0200 [thread overview]
Message-ID: <1370594106-25745-2-git-send-email-dborkman@redhat.com> (raw)
In-Reply-To: <1370594106-25745-1-git-send-email-dborkman@redhat.com>
Release socket related data during sctp_destroy_sock() after we
called sctp_endpoint_free(), but still before we leave the socket
destruction callback. The socket's hmac and bind_hash are only
used in socket.c and actually not in endpointola.c, so also let
it collect the garbage there, no need to go this detour via
endpoints.
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
---
net/sctp/endpointola.c | 7 -------
net/sctp/socket.c | 9 +++++++++
2 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/net/sctp/endpointola.c b/net/sctp/endpointola.c
index 5fbd7bc..ecfba70 100644
--- a/net/sctp/endpointola.c
+++ b/net/sctp/endpointola.c
@@ -248,9 +248,6 @@ static void sctp_endpoint_destroy(struct sctp_endpoint *ep)
{
SCTP_ASSERT(ep->base.dead, "Endpoint is not dead", return);
- /* Free up the HMAC transform. */
- crypto_free_hash(sctp_sk(ep->base.sk)->hmac);
-
/* Free the digest buffer */
kfree(ep->digest);
@@ -270,10 +267,6 @@ 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);
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index f631c5f..3267534 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -4007,7 +4007,16 @@ SCTP_STATIC void sctp_destroy_sock(struct sock *sk)
sp->do_auto_asconf = 0;
list_del(&sp->auto_asconf_list);
}
+
sctp_endpoint_free(sp->ep);
+
+ /* Free up the HMAC transform. */
+ crypto_free_hash(sp->hmac);
+
+ /* Remove and free the port */
+ if (sp->bind_hash)
+ sctp_put_port(sk);
+
local_bh_disable();
percpu_counter_dec(&sctp_sockets_allocated);
sock_prot_inuse_add(sock_net(sk), sk->sk_prot, -1);
--
1.7.11.7
next prev parent reply other threads:[~2013-06-07 8:35 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-07 8:35 [PATCH net-next 0/3] Minor sctp cleanups Daniel Borkmann
2013-06-07 8:35 ` Daniel Borkmann [this message]
2013-06-07 10:54 ` [PATCH net-next 1/3] net: sctp: let sctp_destroy_sock destroy related members Neil Horman
2013-06-07 11:36 ` Daniel Borkmann
2013-06-09 0:20 ` Neil Horman
2013-06-09 9:14 ` Daniel Borkmann
2013-06-07 8:35 ` [PATCH net-next 2/3] net: sctp: sctp_association_init: hold refs in reverse order Daniel Borkmann
2013-06-07 11:00 ` Neil Horman
2013-06-07 11:38 ` Daniel Borkmann
2013-06-09 0:21 ` Neil Horman
2013-06-07 8:35 ` [PATCH net-next 3/3] net: sctp: minor: remove variable in sctp_init_sock Daniel Borkmann
2013-06-07 11:04 ` Neil Horman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1370594106-25745-2-git-send-email-dborkman@redhat.com \
--to=dborkman@redhat.com \
--cc=davem@davemloft.net \
--cc=linux-sctp@vger.kernel.org \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).