Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp1765092rwn; Fri, 9 Sep 2022 03:52:25 -0700 (PDT) X-Google-Smtp-Source: AA6agR40jzrI+bzcI+KqVotC2kwoqN/6YS6g/chjOBA3K6w+2LpNh0C8bE5ZTY50bCX9jD1jE+h4 X-Received: by 2002:a05:6512:1686:b0:491:3199:d407 with SMTP id bu6-20020a056512168600b004913199d407mr4264320lfb.476.1662720745714; Fri, 09 Sep 2022 03:52:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662720745; cv=none; d=google.com; s=arc-20160816; b=KdK3ovC0hqOizFzIYFWAdSXTj24fT1v/Pv72A7j8oQ7GRItQfcvxB0x+dkJLwfh4iE 5mtXYgd7a0wIFJIdpnAsZsX9VazENvw0TcTzOE2mrkFlL8fML1LtllXyXBX9oFszj1Ej lhYoFrf53OWo/aGJmv8OZvEZxohj/LWkEQMcy67aRnSkl+J1v7OYk7+oTyWEwu+YXMnU xJStBJR0N1QWfDyJetG0gLl4lnGwuvyuaep19qZvrLzsgFNwFesC2eQD6gWCWk6GbwfM R+gejGRk05XsS8YDJdDrFYfbBrJObiJ2ul6uDKSheCoOPjR58PYF3VCifc3gCIZKyyBX yImg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:organization :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=HMUz6mnWnjYmmNGj9coEc7oVwu/0r1fyT9PFIS1Amkw=; b=N+nGf6LMaVciA54MIi1HbIVx+fPPAlaxhVi6X+2XtgtUIvMLCtD3ep4fwaYe7uc/wJ p9lTUPoutoeR5YEWOk2Rc7/p+vbiRmu7W224x4rBFzA9KWurs2XuDN3CULVpvZ31CTAz 0+wmEscbxLL6CQ8OerInIOYVHGpSjYqX8XwpW+p/X5S4ETvByxCHqp7Fa07tO+T9v2i2 Xcq1i9FCMhvzDmJwWT82SeIFKaXJQT2NjW8dmPNLShtdTD2DC/WOxVq1NhqgPX3KQ//5 3sNHqGcDFA3QmBPHfHmew1/zcMkGVXfXkV26qMcCbcFjBAe7GrDlxQDKLae5qBXd6YEV 3aJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=QHofpKkp; 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=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k10-20020a192d0a000000b004930187e360si83574lfj.370.2022.09.09.03.51.52; Fri, 09 Sep 2022 03:52:25 -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=@intel.com header.s=Intel header.b=QHofpKkp; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229728AbiIIKuM (ORCPT + 99 others); Fri, 9 Sep 2022 06:50:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229906AbiIIKth (ORCPT ); Fri, 9 Sep 2022 06:49:37 -0400 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA8F411829 for ; Fri, 9 Sep 2022 03:49:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1662720572; x=1694256572; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=x5prW2ah25tO5V4phLQ9GuxORIJy7HrpayGmzP3LVVs=; b=QHofpKkp+a/8a07/n4j9o/lbbMYE2bBkIouQiOE4sdqSHJXKIDc6zDkR NHZe3iuCzWaAmjmfTYopRF7sYhBH5L5XDXeQExoz8QO8GVUjdld+Hn9sX 6jJ+Qglw1Z6Fy1PZXA5mQfsLF0LR3xl86NSitRzdzrdFsZ2YtRz40Vy87 fiHvNHNij8r+l5/JxacEgM+8L18+ooe8fntjSrVxTiFLVebtCU6nrnZqR KVN4z9jyM7ABWhccnI9colj/FH9BTm913KbdS+RvC9GSnRGef0dxAF3qc WxeUXLuYdd5gziXnNQoBDsuxlqBeJwi0wssZLwPE8nNZ0wqVjIdHHlS+i Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10464"; a="295031012" X-IronPort-AV: E=Sophos;i="5.93,303,1654585200"; d="scan'208";a="295031012" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Sep 2022 03:49:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,303,1654585200"; d="scan'208";a="677115260" Received: from silpixa00400314.ir.intel.com (HELO silpixa00400314.ger.corp.intel.com) ([10.237.222.76]) by fmsmga008.fm.intel.com with ESMTP; 09 Sep 2022 03:49:29 -0700 From: Giovanni Cabiddu To: herbert@gondor.apana.org.au Cc: linux-crypto@vger.kernel.org, qat-linux@intel.com, Vlad Dronov , Damian Muszynski , Giovanni Cabiddu , Adam Guerin Subject: [PATCH 3/3] crypto: qat - use reference to structure in dma_map_single() Date: Fri, 9 Sep 2022 11:49:14 +0100 Message-Id: <20220909104914.3351-4-giovanni.cabiddu@intel.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220909104914.3351-1-giovanni.cabiddu@intel.com> References: <20220909104914.3351-1-giovanni.cabiddu@intel.com> MIME-Version: 1.0 Organization: Intel Research and Development Ireland Ltd - Co. Reg. #308263 - Collinstown Industrial Park, Leixlip, County Kildare - Ireland Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_NONE,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: Damian Muszynski When mapping the input and output parameters, the implementations of RSA and DH pass to the function dma_map_single() a pointer to the first member of the structure they want to map instead of a pointer to the actual structure. This results in set of warnings reported by the static analyser Smatch: drivers/crypto/qat/qat_common/qat_asym_algs.c:335 qat_dh_compute_value() error: dma_map_single_attrs() '&qat_req->in.dh.in.b' too small (8 vs 64) drivers/crypto/qat/qat_common/qat_asym_algs.c:341 qat_dh_compute_value() error: dma_map_single_attrs() '&qat_req->out.dh.r' too small (8 vs 64) drivers/crypto/qat/qat_common/qat_asym_algs.c:732 qat_rsa_enc() error: dma_map_single_attrs() '&qat_req->in.rsa.enc.m' too small (8 vs 64) drivers/crypto/qat/qat_common/qat_asym_algs.c:738 qat_rsa_enc() error: dma_map_single_attrs() '&qat_req->out.rsa.enc.c' too small (8 vs 64) drivers/crypto/qat/qat_common/qat_asym_algs.c:878 qat_rsa_dec() error: dma_map_single_attrs() '&qat_req->in.rsa.dec.c' too small (8 vs 64) drivers/crypto/qat/qat_common/qat_asym_algs.c:884 qat_rsa_dec() error: dma_map_single_attrs() '&qat_req->out.rsa.dec.m' too small (8 vs 64) Where the address of the first element of a structure is used as an input for the function dma_map_single(), replace it with the address of the structure. This fix does not introduce any functional change as the addresses are the same. Signed-off-by: Damian Muszynski Signed-off-by: Giovanni Cabiddu Reviewed-by: Adam Guerin --- drivers/crypto/qat/qat_common/qat_asym_algs.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/crypto/qat/qat_common/qat_asym_algs.c b/drivers/crypto/qat/qat_common/qat_asym_algs.c index 85b0f30712e1..94a26702aeae 100644 --- a/drivers/crypto/qat/qat_common/qat_asym_algs.c +++ b/drivers/crypto/qat/qat_common/qat_asym_algs.c @@ -332,13 +332,13 @@ static int qat_dh_compute_value(struct kpp_request *req) qat_req->in.dh.in_tab[n_input_params] = 0; qat_req->out.dh.out_tab[1] = 0; /* Mapping in.in.b or in.in_g2.xa is the same */ - qat_req->phy_in = dma_map_single(dev, &qat_req->in.dh.in.b, + qat_req->phy_in = dma_map_single(dev, &qat_req->in.dh, sizeof(struct qat_dh_input_params), DMA_TO_DEVICE); if (unlikely(dma_mapping_error(dev, qat_req->phy_in))) goto unmap_dst; - qat_req->phy_out = dma_map_single(dev, &qat_req->out.dh.r, + qat_req->phy_out = dma_map_single(dev, &qat_req->out.dh, sizeof(struct qat_dh_output_params), DMA_TO_DEVICE); if (unlikely(dma_mapping_error(dev, qat_req->phy_out))) @@ -729,13 +729,13 @@ static int qat_rsa_enc(struct akcipher_request *req) qat_req->in.rsa.in_tab[3] = 0; qat_req->out.rsa.out_tab[1] = 0; - qat_req->phy_in = dma_map_single(dev, &qat_req->in.rsa.enc.m, + qat_req->phy_in = dma_map_single(dev, &qat_req->in.rsa, sizeof(struct qat_rsa_input_params), DMA_TO_DEVICE); if (unlikely(dma_mapping_error(dev, qat_req->phy_in))) goto unmap_dst; - qat_req->phy_out = dma_map_single(dev, &qat_req->out.rsa.enc.c, + qat_req->phy_out = dma_map_single(dev, &qat_req->out.rsa, sizeof(struct qat_rsa_output_params), DMA_TO_DEVICE); if (unlikely(dma_mapping_error(dev, qat_req->phy_out))) @@ -875,13 +875,13 @@ static int qat_rsa_dec(struct akcipher_request *req) else qat_req->in.rsa.in_tab[3] = 0; qat_req->out.rsa.out_tab[1] = 0; - qat_req->phy_in = dma_map_single(dev, &qat_req->in.rsa.dec.c, + qat_req->phy_in = dma_map_single(dev, &qat_req->in.rsa, sizeof(struct qat_rsa_input_params), DMA_TO_DEVICE); if (unlikely(dma_mapping_error(dev, qat_req->phy_in))) goto unmap_dst; - qat_req->phy_out = dma_map_single(dev, &qat_req->out.rsa.dec.m, + qat_req->phy_out = dma_map_single(dev, &qat_req->out.rsa, sizeof(struct qat_rsa_output_params), DMA_TO_DEVICE); if (unlikely(dma_mapping_error(dev, qat_req->phy_out))) -- 2.37.1