diff --git a/net/sctp/socket.c b/net/sctp/socket.c index a0e879bb202dcb1ad5b0e9a042c03e37daf25b6b..fd7ed9d46a487b58337d9f7fd36dbbc871df6335 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;