aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/algif_hash.c
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2011-06-27 03:45:19 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2011-06-29 19:44:06 -0400
commit269230e7c52623cda279010c8032a6f5b59caaaf (patch)
tree4acb3b9d9e4b1f7b3151d8e91e3201524140893a /crypto/algif_hash.c
parent36ca239b245dbdec3b0c94976e956226bdd4108c (diff)
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>
Diffstat (limited to 'crypto/algif_hash.c')
-rw-r--r--crypto/algif_hash.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/crypto/algif_hash.c b/crypto/algif_hash.c
index 62122a1a2f7a..ef5356cd280a 100644
--- a/crypto/algif_hash.c
+++ b/crypto/algif_hash.c
@@ -68,8 +68,10 @@ static int hash_sendmsg(struct kiocb *unused, struct socket *sock,
68 int newlen; 68 int newlen;
69 69
70 newlen = af_alg_make_sg(&ctx->sgl, from, len, 0); 70 newlen = af_alg_make_sg(&ctx->sgl, from, len, 0);
71 if (newlen < 0) 71 if (newlen < 0) {
72 err = copied ? 0 : newlen;
72 goto unlock; 73 goto unlock;
74 }
73 75
74 ahash_request_set_crypt(&ctx->req, ctx->sgl.sg, NULL, 76 ahash_request_set_crypt(&ctx->req, ctx->sgl.sg, NULL,
75 newlen); 77 newlen);