Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Vlad Yasevich and committed by
David S. Miller
23b29ed8 7dab83de

+3 -2
+3 -2
net/sctp/socket.c
··· 5773 5773 goto out; 5774 5774 5775 5775 /* Allocate HMAC for generating cookie. */ 5776 - if (sctp_hmac_alg) { 5776 + if (!sctp_sk(sk)->hmac && sctp_hmac_alg) { 5777 5777 tfm = crypto_alloc_hash(sctp_hmac_alg, 0, CRYPTO_ALG_ASYNC); 5778 5778 if (IS_ERR(tfm)) { 5779 5779 if (net_ratelimit()) { ··· 5801 5801 goto cleanup; 5802 5802 5803 5803 /* Store away the transform reference. */ 5804 - sctp_sk(sk)->hmac = tfm; 5804 + if (!sctp_sk(sk)->hmac) 5805 + sctp_sk(sk)->hmac = tfm; 5805 5806 out: 5806 5807 sctp_release_sock(sk); 5807 5808 return err;