Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp2657879rwb; Sun, 4 Sep 2022 22:03:04 -0700 (PDT) X-Google-Smtp-Source: AA6agR5Gs5gWtd3ZWZp5d4FRmJZXcZgFSXrSb8SnPC8S3G2vZqsVWsnSzd50cuVsmeo7yybRsv4T X-Received: by 2002:a05:6402:3227:b0:448:706c:185d with SMTP id g39-20020a056402322700b00448706c185dmr29224597eda.357.1662354184213; Sun, 04 Sep 2022 22:03:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662354184; cv=none; d=google.com; s=arc-20160816; b=PC8nqLNnL/4yO1hFBJCP7YoHaxCRPGouwlkfkXfyr/UmLfD9DZJ7A+FZ3ocpwqsd0D diOOp/z9SE1JIuxKqO4IAw3TBTAr7UtjLpo2kO3xa8tyofzwAY1SlAaZHNNYGoiK/OBj FFGPwRv7C18ue1/YY3XKhWm5x+T01zKRv2GrSStRtxIo1BltKNb+EzC1xH6BAFm+T4vo EMXaWIvEQESjI8eyA5CSHt7EzPtmMQjzojvfUPj/NbV3ul2lZbNDGfmT6B7a31AOaD0n 9jMnJfdN3lch4Zfv5T6R1PD07jE6XDOrGqniOkGuBA/C9K/L1bCU7ZDugp+ItK8j62wx fdBw== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=JGmraBTKSYiFxbVbDAsFO1LVNnRKJ1iflFo2iUfCYL4=; b=wLJ0oXX/JqXYsCIakZJ6QeuzSrgtndx4T3hInDAY8XjJU8QscuFSH062RH6eHhDV8A PMO24iHXbNLUeFY47v5h4nAp4YrDzz/ewVAKDVdi+Fyk/oVaEKeD1p9S8deCnSEn8I/0 b9w3IhCcGNeNoLDrRbDsOZaMkcnj+R06xMTwttHBjuezhg0G1h9XPLqDWxR5+YmcbBRb VPOxNPnGRHAknt+gsZTAMK8bMBIxiMP+vzJ9rBajGmOQhNi5YITW9f5n61PTdFxBsL2o WPu2bqrd2L9XlJh7+53K6gRxES0QzyuLzw1Ae5ERFHN59J61FswIgEwae0cHE/+WlF2r 8knw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@maxlinear.com header.s=selector header.b=fjL+n3zo; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=maxlinear.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n3-20020a170906724300b0072b7fac8a7asi5361466ejk.926.2022.09.04.22.02.38; Sun, 04 Sep 2022 22:03:04 -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=@maxlinear.com header.s=selector header.b=fjL+n3zo; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=maxlinear.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235207AbiIEEO6 (ORCPT + 99 others); Mon, 5 Sep 2022 00:14:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233916AbiIEEO4 (ORCPT ); Mon, 5 Sep 2022 00:14:56 -0400 Received: from us-smtp-delivery-115.mimecast.com (us-smtp-delivery-115.mimecast.com [170.10.133.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7022C15835 for ; Sun, 4 Sep 2022 21:14:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=maxlinear.com; s=selector; t=1662351292; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=JGmraBTKSYiFxbVbDAsFO1LVNnRKJ1iflFo2iUfCYL4=; b=fjL+n3zoXH5yAL5ikaV6aVbmqUF+Rckp4kItj0r7h/MliBn9qNOYTDQ59AGOWDFAOo/i8y RKl5j5C1TvsClmqo8pcYlk8jxnZ3IwWNjYSJ+HIv+5FEu98LIj13oPuJoqQ13iUj1QFQ9/ p31NGEA/Q99AMlDqUhE2HD9ER96xvD/40xHG1XHLd0cWnQGKvn8r0Ob/vK0Jwjlg/DyNkz 7Ufb/0rzPga2WylBoY+SmSy3LY4jkWNPozu8BciVne5wXI6a7LPTZRIVR7vPZ65BI/5KdB wF0vZen0bt4VNoMGbpwWx7sn0Yx4YzZJHEECk7YvrN9HzEseQ8lZxj5ntwOdEA== Received: from mail.maxlinear.com (174-47-1-83.static.ctl.one [174.47.1.83]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id us-mta-102-VdGez8wVP1Otcjxlm1bHww-1; Mon, 05 Sep 2022 00:14:51 -0400 X-MC-Unique: VdGez8wVP1Otcjxlm1bHww-1 Received: from sgsxdev002.isng.phoenix.local (10.226.81.112) by mail.maxlinear.com (10.23.38.120) with Microsoft SMTP Server id 15.1.2375.24; Sun, 4 Sep 2022 21:14:48 -0700 From: Peter Harliman Liem To: , CC: , , "Peter Harliman Liem" Subject: [PATCH 1/2] crypto: inside_secure - Avoid dma map if size is zero Date: Mon, 5 Sep 2022 12:14:43 +0800 Message-ID: X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: maxlinear.com Content-Type: text/plain Content-Transfer-Encoding: quoted-printable 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_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 From commit d03c54419274 ("dma-mapping: disallow .map_sg operations from returning zero on error"), dma_map_sg() produces warning if size is 0. This results in visible warnings if crypto length is zero. To avoid that, we avoid calling dma_map_sg if size is zero. Signed-off-by: Peter Harliman Liem --- drivers/crypto/inside-secure/safexcel_cipher.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/crypto/inside-secure/safexcel_cipher.c b/drivers/crypt= o/inside-secure/safexcel_cipher.c index d68ef16650d4..3775497775e0 100644 --- a/drivers/crypto/inside-secure/safexcel_cipher.c +++ b/drivers/crypto/inside-secure/safexcel_cipher.c @@ -737,14 +737,17 @@ static int safexcel_send_req(struct crypto_async_requ= est *base, int ring, =09=09=09=09max(totlen_src, totlen_dst)); =09=09=09return -EINVAL; =09=09} -=09=09dma_map_sg(priv->dev, src, sreq->nr_src, DMA_BIDIRECTIONAL); +=09=09if (sreq->nr_src > 0) +=09=09=09dma_map_sg(priv->dev, src, sreq->nr_src, DMA_BIDIRECTIONAL); =09} else { =09=09if (unlikely(totlen_src && (sreq->nr_src <=3D 0))) { =09=09=09dev_err(priv->dev, "Source buffer not large enough (need %d bytes= )!", =09=09=09=09totlen_src); =09=09=09return -EINVAL; =09=09} -=09=09dma_map_sg(priv->dev, src, sreq->nr_src, DMA_TO_DEVICE); + +=09=09if (sreq->nr_src > 0) +=09=09=09dma_map_sg(priv->dev, src, sreq->nr_src, DMA_TO_DEVICE); =20 =09=09if (unlikely(totlen_dst && (sreq->nr_dst <=3D 0))) { =09=09=09dev_err(priv->dev, "Dest buffer not large enough (need %d bytes)!= ", @@ -753,7 +756,9 @@ static int safexcel_send_req(struct crypto_async_reques= t *base, int ring, =09=09=09=09 DMA_TO_DEVICE); =09=09=09return -EINVAL; =09=09} -=09=09dma_map_sg(priv->dev, dst, sreq->nr_dst, DMA_FROM_DEVICE); + +=09=09if (sreq->nr_dst > 0) +=09=09=09dma_map_sg(priv->dev, dst, sreq->nr_dst, DMA_FROM_DEVICE); =09} =20 =09memcpy(ctx->base.ctxr->data, ctx->key, ctx->key_len); --=20 2.17.1