Skip to content

Commit 24c890d

Browse files
committed
crypto: algif_hash - Remove bogus SGL free on zero-length error path
When a zero-length message is hashed by algif_hash, and an error is triggered, it tries to free an SG list that was never allocated in the first place. Fix this by not freeing the SG list on the zero-length error path. Reported-by: Shigeru Yoshida <[email protected]> Reported-by: xingwei lee <[email protected]> Fixes: b6d972f ("crypto: af_alg/hash: Fix recvmsg() after sendmsg(MSG_MORE)") Cc: <[email protected]> Signed-off-by: Herbert Xu <[email protected]> Reported-by: [email protected] Signed-off-by: Herbert Xu <[email protected]>
1 parent 69fba37 commit 24c890d

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

crypto/algif_hash.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,13 @@ static int hash_sendmsg(struct socket *sock, struct msghdr *msg,
9191
if (!(msg->msg_flags & MSG_MORE)) {
9292
err = hash_alloc_result(sk, ctx);
9393
if (err)
94-
goto unlock_free;
94+
goto unlock_free_result;
9595
ahash_request_set_crypt(&ctx->req, NULL,
9696
ctx->result, 0);
9797
err = crypto_wait_req(crypto_ahash_final(&ctx->req),
9898
&ctx->wait);
9999
if (err)
100-
goto unlock_free;
100+
goto unlock_free_result;
101101
}
102102
goto done_more;
103103
}
@@ -170,6 +170,7 @@ static int hash_sendmsg(struct socket *sock, struct msghdr *msg,
170170

171171
unlock_free:
172172
af_alg_free_sg(&ctx->sgl);
173+
unlock_free_result:
173174
hash_free_result(sk, ctx);
174175
ctx->more = false;
175176
goto unlock;

0 commit comments

Comments
 (0)