From 750d8065d88bc72bd6e1fd9f896a964c35dda818 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Tue, 10 Feb 2015 21:24:55 -0800 Subject: [PATCH] crypto: Fix regressions caused by iov_iter changes. Signed-off-by: Al Viro Signed-off-by: David S. Miller --- crypto/af_alg.c | 2 +- crypto/algif_skcipher.c | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/crypto/af_alg.c b/crypto/af_alg.c index eb78fe8a60c8..5b11d645343d 100644 --- a/crypto/af_alg.c +++ b/crypto/af_alg.c @@ -348,7 +348,7 @@ int af_alg_make_sg(struct af_alg_sgl *sgl, struct iov_iter *iter, int len) if (n < 0) return n; - npages = PAGE_ALIGN(off + n); + npages = DIV_ROUND_UP(off + n, PAGE_SIZE); if (WARN_ON(npages == 0)) return -EINVAL; diff --git a/crypto/algif_skcipher.c b/crypto/algif_skcipher.c index 37110fd68adf..0eb31a69a0a6 100644 --- a/crypto/algif_skcipher.c +++ b/crypto/algif_skcipher.c @@ -427,11 +427,11 @@ static int skcipher_recvmsg(struct kiocb *unused, struct socket *sock, struct skcipher_sg_list *sgl; struct scatterlist *sg; int err = -EAGAIN; - int used; long copied = 0; lock_sock(sk); while (iov_iter_count(&msg->msg_iter)) { + int used; sgl = list_first_entry(&ctx->tsgl, struct skcipher_sg_list, list); sg = sgl->sg; @@ -439,14 +439,13 @@ static int skcipher_recvmsg(struct kiocb *unused, struct socket *sock, while (!sg->length) sg++; - used = ctx->used; - if (!used) { + if (!ctx->used) { err = skcipher_wait_for_data(sk, flags); if (err) goto unlock; } - used = min_t(unsigned long, used, iov_iter_count(&msg->msg_iter)); + used = min_t(unsigned long, ctx->used, iov_iter_count(&msg->msg_iter)); used = af_alg_make_sg(&ctx->rsgl, &msg->msg_iter, used); err = used; -- 2.20.1