Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp3818198rwb; Mon, 5 Sep 2022 20:02:40 -0700 (PDT) X-Google-Smtp-Source: AA6agR6mYNWvBy9qNNiWWY5jemv2iDuvV40WnZU9O09xI/vTwEPv72fTbWakN8xdIhup/W51SguG X-Received: by 2002:a63:6581:0:b0:434:9482:c243 with SMTP id z123-20020a636581000000b004349482c243mr2020857pgb.448.1662433359912; Mon, 05 Sep 2022 20:02:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662433359; cv=none; d=google.com; s=arc-20160816; b=pZDqnAQLD34znkiokslM5Txts03rbhgaCtrxR/WY9upldh0sKdk7ZhblCu76UlHP/n zSC67A59mDw9Jf2OxKqf+K/WcUtwUPxPe2mXg6zNMo0cmpOcNfy73p2C2M5Z2xflaGRI vtKVqiyrkXhhzWxGjbPQezu7WOZR42EJUDnED4k9eg9kG+aSBPikfXVuKhNlmlSls/XQ DcEVXwR2iddJd0MoqXhumINFxdp16DQ9SpgnzPhKj03rSzj9mD5w1bU+KdnZjrQ3UKBX CFkUCCDVIC9bI87MHI9mrmQd/UntTeZqCyV59d5F1IgWiu0ud8t/kRMT1lvyL1aU3gGv QaTA== 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=NM+t79PpSUp/lFULvglYSiTQcuVObzQmfn1c1iAY8wg=; b=jOa+oTiqhvBFw3DraKqvLMYH3IzzA837EQSF7BtAXfYNw2QXmvFVnuZh+XX6rvAN69 92z4T1Xe9GDP8JLH84nhK1B4s/Nr510A42UXH0TefRDc2Sp6jzfEAhgtPrN81S+URy27 jdAHdgp+SvW9NE0sv8Uhb6sMCPgcT42pn0xpqwYlTxdwt3ORSOUNHmwDIzxzDQUsgI+D IhwWFZj/oWUOYK/HneYrt14+NzhGRUcwtP6FTa8nIkac6LJqaaIuD3GtzRmfe3br0wju vefdf4NhrL3rdaEZ0pvzvl8dgux67BqSkA66skAw4/KldB0QI6p//8u2KKYIAWZsJiJE 9S7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@maxlinear.com header.s=selector header.b=kclRZgCB; 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 k22-20020aa788d6000000b0052b8da96658si10509138pff.26.2022.09.05.20.02.08; Mon, 05 Sep 2022 20:02:39 -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=kclRZgCB; 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 S232871AbiIFCwA (ORCPT + 99 others); Mon, 5 Sep 2022 22:52:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231664AbiIFCv5 (ORCPT ); Mon, 5 Sep 2022 22:51:57 -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 F3BA7647C8 for ; Mon, 5 Sep 2022 19:51:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=maxlinear.com; s=selector; t=1662432716; 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=NM+t79PpSUp/lFULvglYSiTQcuVObzQmfn1c1iAY8wg=; b=kclRZgCBhlKIN3/VD2yp9d1XaQYFzsRO4rSGIDRjANXMqTIsJ4IpyIttAN0MQFtkaTs3A/ T+sc9EhGJNgo/Y7NXt54hfck44LHdK1t2pgYSg2Cs8MXVAvm58LrpYSuZSOuDlHnJOwoEd PU4Z44Z8m7jdnmNNCAkMkxH+jCtzfHVTKAXea9JEXHJVeKa3pdUYYqM22JRm94wGwzh3d7 gMjrKK1ScVJ4s1xrfqHh7cNO6RJn3x4QQPnBh4MgzYhuk/P5Jc0JZrKvoNC02A82Nr7qjU JLQ2hFqXEDA/32v6ejyHDZBXSUb+i1e80d58jhM5/ESFEPkbRei+GI5IVZbENA== 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-622-hP6gg1kfOxK7O267I44RQg-1; Mon, 05 Sep 2022 22:51:55 -0400 X-MC-Unique: hP6gg1kfOxK7O267I44RQg-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; Mon, 5 Sep 2022 19:51:53 -0700 From: Peter Harliman Liem To: , CC: , , "Peter Harliman Liem" Subject: [PATCH v2 1/2] crypto: inside_secure - Avoid dma map if size is zero Date: Tue, 6 Sep 2022 10:51:49 +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. Fixes: d03c54419274 ("dma-mapping: disallow .map_sg operations from returni= ng zero on error") Signed-off-by: Peter Harliman Liem --- v2: Add fixes tag 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