Skip to content

Commit

Permalink
sctp: Do not leak memory on multiple listen() calls
Browse files Browse the repository at this point in the history
SCTP permits multiple listen call and on subsequent calls
we leak he memory allocated for the crypto transforms.

Signed-off-by: Vlad Yasevich <vladislav.yasevich@hp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Vlad Yasevich authored and David S. Miller committed Jul 19, 2008
1 parent 7dab83d commit 23b29ed
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions net/sctp/socket.c
Original file line number Diff line number Diff line change
@@ -5773,7 +5773,7 @@ int sctp_inet_listen(struct socket *sock, int backlog)
goto out;

/* Allocate HMAC for generating cookie. */
if (sctp_hmac_alg) {
if (!sctp_sk(sk)->hmac && sctp_hmac_alg) {
tfm = crypto_alloc_hash(sctp_hmac_alg, 0, CRYPTO_ALG_ASYNC);
if (IS_ERR(tfm)) {
if (net_ratelimit()) {
@@ -5801,7 +5801,8 @@ int sctp_inet_listen(struct socket *sock, int backlog)
goto cleanup;

/* Store away the transform reference. */
sctp_sk(sk)->hmac = tfm;
if (!sctp_sk(sk)->hmac)
sctp_sk(sk)->hmac = tfm;
out:
sctp_release_sock(sk);
return err;

0 comments on commit 23b29ed

Please sign in to comment.