summaryrefslogtreecommitdiff
path: root/crypto
diff options
context:
space:
mode:
Diffstat (limited to 'crypto')
-rw-r--r--crypto/algif_skcipher.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/crypto/algif_skcipher.c b/crypto/algif_skcipher.c
index 1f33480e326..6a6dfc062d2 100644
--- a/crypto/algif_skcipher.c
+++ b/crypto/algif_skcipher.c
@@ -454,17 +454,17 @@ static int skcipher_recvmsg(struct kiocb *unused, struct socket *sock,
used = min_t(unsigned long, used, seglen);
+ used = af_alg_make_sg(&ctx->rsgl, from, used, 1);
+ err = used;
+ if (err < 0)
+ goto unlock;
+
if (ctx->more || used < ctx->used)
used -= used % bs;
err = -EINVAL;
if (!used)
- goto unlock;
-
- used = af_alg_make_sg(&ctx->rsgl, from, used, 1);
- err = used;
- if (err < 0)
- goto unlock;
+ goto free;
ablkcipher_request_set_crypt(&ctx->req, sg,
ctx->rsgl.sg, used,
@@ -476,6 +476,7 @@ static int skcipher_recvmsg(struct kiocb *unused, struct socket *sock,
crypto_ablkcipher_decrypt(&ctx->req),
&ctx->completion);
+free:
af_alg_free_sg(&ctx->rsgl);
if (err)