diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2015-12-30 20:24:17 +0800 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2016-01-18 18:16:10 +0800 |
commit | a383292c86663bbc31ac62cc0c04fc77504636a6 (patch) | |
tree | dbc55e2abd13c348dfe6aac886102b5bb3293bed | |
parent | c840ac6af3f8713a71b4d2363419145760bd6044 (diff) | |
download | linux-stable-a383292c86663bbc31ac62cc0c04fc77504636a6.tar.gz linux-stable-a383292c86663bbc31ac62cc0c04fc77504636a6.tar.bz2 linux-stable-a383292c86663bbc31ac62cc0c04fc77504636a6.zip |
crypto: af_alg - Fix socket double-free when accept fails
When we fail an accept(2) call we will end up freeing the socket
twice, once due to the direct sk_free call and once again through
newsock.
This patch fixes this by removing the sk_free call.
Cc: stable@vger.kernel.org
Reported-by: Dmitry Vyukov <dvyukov@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
-rw-r--r-- | crypto/af_alg.c | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/crypto/af_alg.c b/crypto/af_alg.c index 7b5b5926c767..eaf98e287d89 100644 --- a/crypto/af_alg.c +++ b/crypto/af_alg.c @@ -285,10 +285,8 @@ int af_alg_accept(struct sock *sk, struct socket *newsock) security_sk_clone(sk, sk2); err = type->accept(ask->private, sk2); - if (err) { - sk_free(sk2); + if (err) goto unlock; - } sk2->sk_family = PF_ALG; |