diff options
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/algif_hash.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/crypto/algif_hash.c b/crypto/algif_hash.c index 2d8466f9e49b..05e21b464433 100644 --- a/crypto/algif_hash.c +++ b/crypto/algif_hash.c | |||
@@ -214,23 +214,26 @@ static int hash_recvmsg(struct socket *sock, struct msghdr *msg, size_t len, | |||
214 | 214 | ||
215 | ahash_request_set_crypt(&ctx->req, NULL, ctx->result, 0); | 215 | ahash_request_set_crypt(&ctx->req, NULL, ctx->result, 0); |
216 | 216 | ||
217 | if (ctx->more) { | 217 | if (!result) { |
218 | err = af_alg_wait_for_completion( | ||
219 | crypto_ahash_init(&ctx->req), | ||
220 | &ctx->completion); | ||
221 | if (err) | ||
222 | goto unlock; | ||
223 | } | ||
224 | |||
225 | if (!result || ctx->more) { | ||
218 | ctx->more = 0; | 226 | ctx->more = 0; |
219 | err = af_alg_wait_for_completion(crypto_ahash_final(&ctx->req), | 227 | err = af_alg_wait_for_completion(crypto_ahash_final(&ctx->req), |
220 | &ctx->completion); | 228 | &ctx->completion); |
221 | if (err) | 229 | if (err) |
222 | goto unlock; | 230 | goto unlock; |
223 | } else if (!result) { | ||
224 | err = af_alg_wait_for_completion( | ||
225 | crypto_ahash_digest(&ctx->req), | ||
226 | &ctx->completion); | ||
227 | } | 231 | } |
228 | 232 | ||
229 | err = memcpy_to_msg(msg, ctx->result, len); | 233 | err = memcpy_to_msg(msg, ctx->result, len); |
230 | 234 | ||
231 | hash_free_result(sk, ctx); | ||
232 | |||
233 | unlock: | 235 | unlock: |
236 | hash_free_result(sk, ctx); | ||
234 | release_sock(sk); | 237 | release_sock(sk); |
235 | 238 | ||
236 | return err ?: len; | 239 | return err ?: len; |