Skip to content

Commit a383292

Browse files
committed
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: [email protected] Reported-by: Dmitry Vyukov <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent c840ac6 commit a383292

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

crypto/af_alg.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -285,10 +285,8 @@ int af_alg_accept(struct sock *sk, struct socket *newsock)
285285
security_sk_clone(sk, sk2);
286286

287287
err = type->accept(ask->private, sk2);
288-
if (err) {
289-
sk_free(sk2);
288+
if (err)
290289
goto unlock;
291-
}
292290

293291
sk2->sk_family = PF_ALG;
294292

0 commit comments

Comments
 (0)