From patchwork Fri Apr 28 17:02:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Logan Gunthorpe X-Patchwork-Id: 9705125 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2AE1860225 for ; Fri, 28 Apr 2017 17:03:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1911A28695 for ; Fri, 28 Apr 2017 17:03:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0D8A728697; Fri, 28 Apr 2017 17:03:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 759A528695 for ; Fri, 28 Apr 2017 17:03:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755338AbdD1RDz (ORCPT ); Fri, 28 Apr 2017 13:03:55 -0400 Received: from ale.deltatee.com ([207.54.116.67]:60759 "EHLO ale.deltatee.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755333AbdD1RDy (ORCPT ); Fri, 28 Apr 2017 13:03:54 -0400 Received: from cgy1-donard.priv.deltatee.com ([172.16.1.31]) by ale.deltatee.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1d49J6-0000PF-MC; Fri, 28 Apr 2017 11:03:51 -0600 Received: from gunthorp by cgy1-donard.priv.deltatee.com with local (Exim 4.84_2) (envelope-from ) id 1d49J7-0006gJ-M7; Fri, 28 Apr 2017 11:03:49 -0600 From: Logan Gunthorpe To: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Logan Gunthorpe , Herbert Xu , "David S. Miller" Date: Fri, 28 Apr 2017 11:02:40 -0600 Message-Id: <1493398960-25643-1-git-send-email-logang@deltatee.com> X-Mailer: git-send-email 2.1.4 X-SA-Exim-Connect-IP: 172.16.1.31 X-SA-Exim-Rcpt-To: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, logang@deltatee.com, herbert@gondor.apana.org.au, davem@davemloft.net X-SA-Exim-Mail-From: gunthorp@deltatee.com Subject: [PATCH] crypto: hifn_795x: Fix a handful of minor bugs spotted by eye X-SA-Exim-Version: 4.2.1 (built Mon, 26 Dec 2011 16:24:06 +0000) X-SA-Exim-Scanned: Yes (on ale.deltatee.com) Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP * 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 Cc: Herbert Xu Cc: "David S. Miller" --- 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);