Skip to content

Commit 269230e

Browse files
committed
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: Jesper Juhl <jj@chaosbits.net> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent 36ca239 commit 269230e

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

crypto/algif_hash.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,10 @@ static int hash_sendmsg(struct kiocb *unused, struct socket *sock,
6868
int newlen;
6969

7070
newlen = af_alg_make_sg(&ctx->sgl, from, len, 0);
71-
if (newlen < 0)
71+
if (newlen < 0) {
72+
err = copied ? 0 : newlen;
7273
goto unlock;
74+
}
7375

7476
ahash_request_set_crypt(&ctx->req, ctx->sgl.sg, NULL,
7577
newlen);

0 commit comments

Comments
 (0)