mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Logan Gunthorpe <logang@deltatee.com>
To: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Logan Gunthorpe <logang@deltatee.com>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	"David S. Miller" <davem@davemloft.net>
Subject: [PATCH] crypto: hifn_795x: Fix a handful of minor bugs spotted by eye
Date: Fri, 28 Apr 2017 11:02:40 -0600	[thread overview]
Message-ID: <1493398960-25643-1-git-send-email-logang@deltatee.com> (raw)

* Cleaned up the formatting of ablkcipher_get arguments so it complies
  with kernel style
* The offset in ablkcipher_get sould be added to the source, not the
  destination. We rename it to soffset for clarity.
* dst++ should be dst=sg_next(dst)
* We call kunmap_atomic earlier so we only have to do it once.
* If ablkcipher_get fails, we should probably ensure the request
  completes with an error.

Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
Cc: Herbert Xu <herbert@gondor.apana.org.au>
Cc: "David S. Miller" <davem@davemloft.net>
---
 drivers/crypto/hifn_795x.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/drivers/crypto/hifn_795x.c b/drivers/crypto/hifn_795x.c
index e09d405..4c19e4a 100644
--- a/drivers/crypto/hifn_795x.c
+++ b/drivers/crypto/hifn_795x.c
@@ -1619,8 +1619,9 @@ static int hifn_start_device(struct hifn_device *dev)
 	return 0;
 }
 
-static int ablkcipher_get(void *saddr, unsigned int *srestp, unsigned int offset,
-		struct scatterlist *dst, unsigned int size, unsigned int *nbytesp)
+static int ablkcipher_get(void *saddr, unsigned int *srestp,
+			  unsigned int soffset, struct scatterlist *dst,
+			  unsigned int size, unsigned int *nbytesp)
 {
 	unsigned int srest = *srestp, nbytes = *nbytesp, copy;
 	void *daddr;
@@ -1633,19 +1634,19 @@ static int ablkcipher_get(void *saddr, unsigned int *srestp, unsigned int offset
 		copy = min3(srest, dst->length, size);
 
 		daddr = kmap_atomic(sg_page(dst));
-		memcpy(daddr + dst->offset + offset, saddr, copy);
+		memcpy(daddr + dst->offset, saddr + soffset, copy);
 		kunmap_atomic(daddr);
 
 		nbytes -= copy;
 		size -= copy;
 		srest -= copy;
 		saddr += copy;
-		offset = 0;
+		soffset = 0;
 
 		pr_debug("%s: copy: %u, size: %u, srest: %u, nbytes: %u.\n",
 			 __func__, copy, size, srest, nbytes);
 
-		dst++;
+		dst = sg_next(dst);
 		idx++;
 	}
 
@@ -1699,13 +1700,15 @@ static void hifn_process_ready(struct ablkcipher_request *req, int error)
 
 			err = ablkcipher_get(saddr, &t->length, t->offset,
 					dst, nbytes, &nbytes);
+			kunmap_atomic(saddr);
+
 			if (err < 0) {
-				kunmap_atomic(saddr);
+				if (!error)
+					error = err;
 				break;
 			}
 
 			idx += err;
-			kunmap_atomic(saddr);
 		}
 
 		hifn_cipher_walk_exit(&rctx->walk);
-- 
2.1.4

             reply	other threads:[~2017-04-28 17:04 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-28 17:02 Logan Gunthorpe [this message]
2017-05-18  3:25 ` Herbert Xu
2017-05-18  3:26   ` Herbert Xu
2017-05-18  3:33     ` Logan Gunthorpe
2017-05-18  4:02       ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1493398960-25643-1-git-send-email-logang@deltatee.com \
    --to=logang@deltatee.com \
    --cc=davem@davemloft.net \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome