Commit 269230e7 authored by Herbert Xu's avatar Herbert Xu

crypto: algif_hash - Handle initial af_alg_make_sg error correctly

When the first call to af_alg_make_sg fails, we may return garbage
instead of the real error.  This patch fixes it by setting the error
if "copied" is zero.

Based on a patch by Jesper Juhl.
Reported-by: default avatarJesper Juhl <jj@chaosbits.net>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 36ca239b
...@@ -68,8 +68,10 @@ static int hash_sendmsg(struct kiocb *unused, struct socket *sock, ...@@ -68,8 +68,10 @@ static int hash_sendmsg(struct kiocb *unused, struct socket *sock,
int newlen; int newlen;
newlen = af_alg_make_sg(&ctx->sgl, from, len, 0); newlen = af_alg_make_sg(&ctx->sgl, from, len, 0);
if (newlen < 0) if (newlen < 0) {
err = copied ? 0 : newlen;
goto unlock; goto unlock;
}
ahash_request_set_crypt(&ctx->req, ctx->sgl.sg, NULL, ahash_request_set_crypt(&ctx->req, ctx->sgl.sg, NULL,
newlen); newlen);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment