summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorVlad Yasevich <vladislav.yasevich@hp.com>2008-07-18 23:06:07 -0700
committerDavid S. Miller <davem@davemloft.net>2008-07-18 23:06:07 -0700
commit23b29ed80bd7184398317a111dc488605cb66c7f (patch)
treebe2d87726f00ebb21d10fc62c2b4ba557a7392eb /net
parent7dab83de50c7b2b7ceac695a0b56fa6c0f95b0bc (diff)
downloadlinux-23b29ed80bd7184398317a111dc488605cb66c7f.tar.gz
linux-23b29ed80bd7184398317a111dc488605cb66c7f.tar.bz2
linux-23b29ed80bd7184398317a111dc488605cb66c7f.zip
sctp: Do not leak memory on multiple listen() calls
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>
Diffstat (limited to 'net')
-rw-r--r--net/sctp/socket.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index a0e879bb202d..fd7ed9d46a48 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -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;