Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp1237951rwb; Thu, 18 Aug 2022 23:09:53 -0700 (PDT) X-Google-Smtp-Source: AA6agR4Aq1wCUtB8Xq15UHkvlKVmXtDdXiszGRMCvSA+cnLkQXuMYp5BdW8cmnvjbQkokjVMK6N7 X-Received: by 2002:aa7:88cf:0:b0:52f:fdad:9e0 with SMTP id k15-20020aa788cf000000b0052ffdad09e0mr6358870pff.74.1660889393269; Thu, 18 Aug 2022 23:09:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660889393; cv=none; d=google.com; s=arc-20160816; b=gOD2Zkn55ob1PjvcZ112/xboO0cTjhAdJAkHVXtBZh+6HLwtRb7uPUKdbs3hV80h+P we0w0325alZD5f1S38Cjg6WVRLjn9mr3KaUoTC8WYv1CULM7SV5uKw2Ft2zoymXK90gC clQ+W34e2DvcPt9TYwxoraSA6A6PAtdg1v/K1XruvwQvRV0fKL1BRDI/BWhVnKbKGY07 xI67RmaoYg0mdYj/iQjkDgZwovYIPf9/VovNEooKuHqIDqjqCCpOp77UrDwU+PrORqzY +PehEbnelr3IVB2k0w8YJ9sw65ZVsJMPMEzLDDJCZUU+TxQjulGjYYmolozeGUaCgdfL SU8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=5gJkiTR+kGRLtGgVd47CicF8SNS8UY18L9XUin4OY2Y=; b=R8pijlHkVdKwVU52cGFrr5rDCjMatTSbFQKqHku7oOUpB+HKqSJR0yn4beDUC5M7dc iPJTl4lQCCj8outovDA74AxrSVBUPk9vLcjSF9iVleIvKmHf6ObZVogV3PTGSjITuL6S /m+SMEJjUB8fR9FLBcmX303XX2nwc/Dbis4eofP818k0nUiBKvwYcjOYrHUa52poBbq7 gAqTSL9iEOiBtMNF38ekxx0vtav7Sar2ta9xWaHXMVJvbDpPosXBmgptpludRzjmPtvM P4w66DYYnuMVNogT4FcegQXs1uFRnCy2irJpPSDLMBL1DHyRN766P9Mo0Fs92uEX3rij Px5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=QJC4IJlQ; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ionos.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k16-20020a170902d59000b00172adace273si2921934plh.535.2022.08.18.23.09.40; Thu, 18 Aug 2022 23:09:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=QJC4IJlQ; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ionos.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346600AbiHSGIv (ORCPT + 99 others); Fri, 19 Aug 2022 02:08:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346527AbiHSGId (ORCPT ); Fri, 19 Aug 2022 02:08:33 -0400 Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 245AA1FCE9 for ; Thu, 18 Aug 2022 23:08:19 -0700 (PDT) Received: by mail-ed1-x534.google.com with SMTP id z2so4457406edc.1 for ; Thu, 18 Aug 2022 23:08:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=5gJkiTR+kGRLtGgVd47CicF8SNS8UY18L9XUin4OY2Y=; b=QJC4IJlQ/pc53o+D11jC62z/3fhQ5SotDCbo5C5orgKX9ZXhpy96Sv15+GEhv6RP+G mrqO821gPfoqnBrUz0Pt1mdZBC7U0OIwQtGUeZHKroZt28gFxn1D4vhYT4/byi/4ACXS 0Oc1eKBWrKxD+RJKPtaXXTHwrCsqVefIZIni+tQ/LWKxtsrTymFXxkO2gJgQ99ozgjKX iGxLfMcpdIkhS9BbSA9nwWk2FjQCCCsKcEmYr+qDKpN1Gq2yXXILl8CF25Aw5O0Jy7bR kQcpxeHm18TpANDu7+SIayoh6NdnbkYKG6/jA5VrzTKRTWDRCMl9o+vUxdzr5Rkhq2ha xXDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=5gJkiTR+kGRLtGgVd47CicF8SNS8UY18L9XUin4OY2Y=; b=UWgKqLHj6T2QRGhX8J1FcilV9iR1uiewlSievCAl+YqiFAC8Mmncno8u5EiUq0Elza +hpxYeJck/P+3227YaSLJgHVURNmPCjALYrRT3g1ULp5FXFCtPdToRENlKsvIVzw5BG6 plIbUYCaXQFDIJRG36Yl+uXjU6EycUzBfV9bIGS1k1IlhhSwHxs9VDHHzKWb/nAaMWtX YrGjUGSJDRTYzhWUpI4WSQmvMM1d7tHqapReydm34JfO82BttajqPIYbxtJDhyRY8aJ2 ow6K78bLHC554Lhs6jJ9qWt04XGosh22Aftpd1jPJaDpcPZxK21TsHqteWf+ums7ANN4 p/2g== X-Gm-Message-State: ACgBeo0t/+qO6zmKQPCSbnwxSTARfsTGjOkGYbxA/dBPgXxAKqU38BY+ XUVFjW0eYzLsj0V1Dwg68htCmdVBKj4srg9R X-Received: by 2002:a05:6402:191:b0:445:cf66:25c5 with SMTP id r17-20020a056402019100b00445cf6625c5mr4865875edv.58.1660889298374; Thu, 18 Aug 2022 23:08:18 -0700 (PDT) Received: from lb02065.fritz.box ([2001:9e8:143b:fd00:5207:8c7f:747a:b80d]) by smtp.gmail.com with ESMTPSA id y14-20020a1709063a8e00b0073a644ef803sm1809660ejd.101.2022.08.18.23.08.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Aug 2022 23:08:17 -0700 (PDT) From: Jack Wang To: linux-kernel@vger.kernel.org Cc: Thara Gopinath , Herbert Xu , "David S. Miller" , linux-crypto@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [PATCH v1 09/19] crypto: qce: Fix dma_map_sg error check Date: Fri, 19 Aug 2022 08:07:51 +0200 Message-Id: <20220819060801.10443-10-jinpu.wang@ionos.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220819060801.10443-1-jinpu.wang@ionos.com> References: <20220819060801.10443-1-jinpu.wang@ionos.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org dma_map_sg return 0 on error, fix the error check and return -EIO to caller. Cc: Thara Gopinath Cc: Herbert Xu Cc: "David S. Miller" Cc: linux-crypto@vger.kernel.org Cc: linux-arm-msm@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Jack Wang --- drivers/crypto/qce/aead.c | 4 ++-- drivers/crypto/qce/sha.c | 8 +++++--- drivers/crypto/qce/skcipher.c | 8 ++++---- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/drivers/crypto/qce/aead.c b/drivers/crypto/qce/aead.c index 97a530171f07..6eb4d2e35629 100644 --- a/drivers/crypto/qce/aead.c +++ b/drivers/crypto/qce/aead.c @@ -450,8 +450,8 @@ qce_aead_async_req_handle(struct crypto_async_request *async_req) if (ret) return ret; dst_nents = dma_map_sg(qce->dev, rctx->dst_sg, rctx->dst_nents, dir_dst); - if (dst_nents < 0) { - ret = dst_nents; + if (!dst_nents) { + ret = -EIO; goto error_free; } diff --git a/drivers/crypto/qce/sha.c b/drivers/crypto/qce/sha.c index 59159f5e64e5..37bafd7aeb79 100644 --- a/drivers/crypto/qce/sha.c +++ b/drivers/crypto/qce/sha.c @@ -97,14 +97,16 @@ static int qce_ahash_async_req_handle(struct crypto_async_request *async_req) } ret = dma_map_sg(qce->dev, req->src, rctx->src_nents, DMA_TO_DEVICE); - if (ret < 0) - return ret; + if (!ret) + return -EIO; sg_init_one(&rctx->result_sg, qce->dma.result_buf, QCE_RESULT_BUF_SZ); ret = dma_map_sg(qce->dev, &rctx->result_sg, 1, DMA_FROM_DEVICE); - if (ret < 0) + if (!ret) { + ret = -EIO; goto error_unmap_src; + } ret = qce_dma_prep_sgs(&qce->dma, req->src, rctx->src_nents, &rctx->result_sg, 1, qce_ahash_done, async_req); diff --git a/drivers/crypto/qce/skcipher.c b/drivers/crypto/qce/skcipher.c index 3d27cd5210ef..5b493fdc1e74 100644 --- a/drivers/crypto/qce/skcipher.c +++ b/drivers/crypto/qce/skcipher.c @@ -124,15 +124,15 @@ qce_skcipher_async_req_handle(struct crypto_async_request *async_req) rctx->dst_sg = rctx->dst_tbl.sgl; dst_nents = dma_map_sg(qce->dev, rctx->dst_sg, rctx->dst_nents, dir_dst); - if (dst_nents < 0) { - ret = dst_nents; + if (!dst_nents) { + ret = -EIO; goto error_free; } if (diff_dst) { src_nents = dma_map_sg(qce->dev, req->src, rctx->src_nents, dir_src); - if (src_nents < 0) { - ret = src_nents; + if (!src_nents) { + ret = -EIO; goto error_unmap_dst; } rctx->src_sg = req->src; -- 2.34.1