提交 23b29ed8 编写于 作者: V Vlad Yasevich 提交者: David S. Miller

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: NVlad Yasevich <vladislav.yasevich@hp.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 7dab83de
...@@ -5773,7 +5773,7 @@ int sctp_inet_listen(struct socket *sock, int backlog) ...@@ -5773,7 +5773,7 @@ int sctp_inet_listen(struct socket *sock, int backlog)
goto out; goto out;
/* Allocate HMAC for generating cookie. */ /* 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); tfm = crypto_alloc_hash(sctp_hmac_alg, 0, CRYPTO_ALG_ASYNC);
if (IS_ERR(tfm)) { if (IS_ERR(tfm)) {
if (net_ratelimit()) { if (net_ratelimit()) {
...@@ -5801,6 +5801,7 @@ int sctp_inet_listen(struct socket *sock, int backlog) ...@@ -5801,6 +5801,7 @@ int sctp_inet_listen(struct socket *sock, int backlog)
goto cleanup; goto cleanup;
/* Store away the transform reference. */ /* Store away the transform reference. */
if (!sctp_sk(sk)->hmac)
sctp_sk(sk)->hmac = tfm; sctp_sk(sk)->hmac = tfm;
out: out:
sctp_release_sock(sk); sctp_release_sock(sk);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册