2.4.36-stable kernel tree
Revision | 457b8910e4deb9f83b821ae25ae03a0d593df625 (tree) |
---|---|
Time | 2008-09-06 20:35:25 |
Author | Vlad Yasevich <vladislav.yasevich@hp.c...> |
Commiter | Willy Tarreau |
sctp: Do not leak memory on multiple listen() calls
[backport of 2.6 commit 23b29ed80bd7184398317a111dc488605cb66c7f]
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>
Signed-off-by: Willy Tarreau <w@1wt.eu>
@@ -3985,7 +3985,7 @@ int sctp_inet_listen(struct socket *sock, int backlog) | ||
3985 | 3985 | goto out; |
3986 | 3986 | |
3987 | 3987 | /* Allocate HMAC for generating cookie. */ |
3988 | - if (sctp_hmac_alg) { | |
3988 | + if (!sctp_sk(sk)->hmac && sctp_hmac_alg) { | |
3989 | 3989 | tfm = sctp_crypto_alloc_tfm(sctp_hmac_alg, 0); |
3990 | 3990 | if (!tfm) { |
3991 | 3991 | err = -ENOSYS; |
@@ -4007,7 +4007,8 @@ int sctp_inet_listen(struct socket *sock, int backlog) | ||
4007 | 4007 | goto cleanup; |
4008 | 4008 | |
4009 | 4009 | /* Store away the transform reference. */ |
4010 | - sctp_sk(sk)->hmac = tfm; | |
4010 | + if (!sctp_sk(sk)->hmac) | |
4011 | + sctp_sk(sk)->hmac = tfm; | |
4011 | 4012 | out: |
4012 | 4013 | sctp_release_sock(sk); |
4013 | 4014 | return err; |