From patchwork Mon Jun 19 10:51:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 9795761 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 2A103600C5 for ; Mon, 19 Jun 2017 10:52:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E0AA327D4D for ; Mon, 19 Jun 2017 10:52:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D323D27EE2; Mon, 19 Jun 2017 10:52:01 +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, UNPARSEABLE_RELAY 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 5F35627D4D for ; Mon, 19 Jun 2017 10:52:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753823AbdFSKv7 (ORCPT ); Mon, 19 Jun 2017 06:51:59 -0400 Received: from aserp1040.oracle.com ([141.146.126.69]:44936 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753868AbdFSKv7 (ORCPT ); Mon, 19 Jun 2017 06:51:59 -0400 Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id v5JApmwB015226 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 19 Jun 2017 10:51:48 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id v5JApmuk023697 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 19 Jun 2017 10:51:48 GMT Received: from abhmp0013.oracle.com (abhmp0013.oracle.com [141.146.116.19]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id v5JApkn1011901; Mon, 19 Jun 2017 10:51:47 GMT Received: from elgon.mountain (/129.205.6.86) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 19 Jun 2017 03:51:44 -0700 Date: Mon, 19 Jun 2017 13:51:25 +0300 From: Dan Carpenter To: Herbert Xu , Srikanth Jampala Cc: "David S. Miller" , linux-crypto@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH] crypto: cavium/nitrox - dma_mapping_error() returns bool Message-ID: <20170619105124.GA23831@elgon.mountain> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-Source-IP: userv0021.oracle.com [156.151.31.71] 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 We want to return negative error codes here, but we're accidentally propogating the "true" return from dma_mapping_error(). Fixes: 14fa93cdcd9b ("crypto: cavium - Add support for CNN55XX adapters.") Signed-off-by: Dan Carpenter diff --git a/drivers/crypto/cavium/nitrox/nitrox_reqmgr.c b/drivers/crypto/cavium/nitrox/nitrox_reqmgr.c index b6bd2a870028..4bb4377c5ac0 100644 --- a/drivers/crypto/cavium/nitrox/nitrox_reqmgr.c +++ b/drivers/crypto/cavium/nitrox/nitrox_reqmgr.c @@ -199,9 +199,10 @@ static int dma_map_inbufs(struct nitrox_softreq *sr, sr->in.sglist = glist; /* map IV */ dma = dma_map_single(dev, &req->iv, req->ivsize, DMA_BIDIRECTIONAL); - ret = dma_mapping_error(dev, dma); - if (ret) + if (dma_mapping_error(dev, dma)) { + ret = -EINVAL; goto iv_map_err; + } sr->in.dir = (req->src == req->dst) ? DMA_BIDIRECTIONAL : DMA_TO_DEVICE; /* map src entries */ @@ -268,16 +269,18 @@ static int dma_map_outbufs(struct nitrox_softreq *sr, /* map ORH */ sr->resp.orh_dma = dma_map_single(dev, &sr->resp.orh, ORH_HLEN, sr->out.dir); - ret = dma_mapping_error(dev, sr->resp.orh_dma); - if (ret) + if (dma_mapping_error(dev, sr->resp.orh_dma)) { + ret = -EINVAL; goto orh_map_err; + } /* map completion */ sr->resp.completion_dma = dma_map_single(dev, &sr->resp.completion, COMP_HLEN, sr->out.dir); - ret = dma_mapping_error(dev, sr->resp.completion_dma); - if (ret) + if (dma_mapping_error(dev, sr->resp.completion_dma)) { + ret = -EINVAL; goto compl_map_err; + } sr->inplace = (req->src == req->dst) ? true : false; /* out place */