Skip to content

Commit

Permalink
crypto: algif_hash - Handle initial af_alg_make_sg error correctly
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>
  • Loading branch information
herbertx committed Jun 29, 2011
1 parent 36ca239 commit 269230e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion crypto/algif_hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,10 @@ static int hash_sendmsg(struct kiocb *unused, struct socket *sock,
int newlen;

newlen = af_alg_make_sg(&ctx->sgl, from, len, 0);
if (newlen < 0)
if (newlen < 0) {
err = copied ? 0 : newlen;
goto unlock;
}

ahash_request_set_crypt(&ctx->req, ctx->sgl.sg, NULL,
newlen);
Expand Down

0 comments on commit 269230e

Please sign in to comment.