From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2CE23A0A02 for ; Fri, 21 May 2021 04:00:17 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0495040041; Fri, 21 May 2021 04:00:17 +0200 (CEST) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mails.dpdk.org (Postfix) with ESMTP id 35F4D40041; Fri, 21 May 2021 04:00:15 +0200 (CEST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 9ECB5101E; Thu, 20 May 2021 19:00:14 -0700 (PDT) Received: from net-x86-dell-8268.shanghai.arm.com (net-x86-dell-8268.shanghai.arm.com [10.169.210.132]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id BB7143F73D; Thu, 20 May 2021 19:00:10 -0700 (PDT) From: Feifei Wang To: John Griffin , Fiona Trahe , Deepak Kumar Jain , Jerin Jacob , Herbert Guan Cc: dev@dpdk.org, ferruh.yigit@intel.com, adamx.dybkowski@intel.com, nd@arm.com, Feifei Wang , stable@dpdk.org, Ruifeng Wang , Honnappa Nagarahalli Date: Fri, 21 May 2021 10:00:04 +0800 Message-Id: <20210521020004.100034-1-feifei.wang2@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210514074113.2666225-1-feifei.wang2@arm.com> References: <20210514074113.2666225-1-feifei.wang2@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] [PATCH v5] crypto/qat: fix uninitialized gcc compiler warning X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" In Arm platform, when "RTE_ARCH_ARM64_MEMCPY" is set as true, gcc will report variable uninitialized warning: ../drivers/crypto/qat/qat_sym_session.c: In function ‘partial_hash_compute’: ../lib/eal/include/generic/rte_byteorder.h:241:24: warning: ‘’ may be used uninitialized in this function [-Wmaybe-uninitialized] 241 | #define rte_bswap32(x) __builtin_bswap32(x) ... This is because "digest" will be initialized by "rte_memcpy" function rather than "memcpy" if "RTE_ARCH_ARM64_MEMCPY" is set as true. Furthermore, 'rte_memcpy' will initialize 'digest' with two steps by invoking rte_mov_x functions. For example: partial_hash_sha1 -> rte_memcpy -> rte_memcpy_ge16_lt_128 -> step 1: rte_mov16(dst,src ) step 2: rte_mov16(dst - 16 + n, src - 16 + n) However, gcc compiler cannot identify this multi-step initialization, then it will report warning. To fix this, use "memset" to initialize "digest". Fixes: cd7fc8a84b48 ("eal/arm64: optimize memcpy") Cc: stable@dpdk.org Signed-off-by: Feifei Wang Reviewed-by: Ruifeng Wang Reviewed-by: Honnappa Nagarahalli Acked-by: Adam Dybkowski --- v2: add check and free for memory dynamic allocation (David Marchand) v3: fix compiler error v4: use 'memset' to initialize digest (Ferruh, Adam) v5: fixed spelling errors in commit message (Honnappa) drivers/crypto/qat/qat_sym_session.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/crypto/qat/qat_sym_session.c b/drivers/crypto/qat/qat_sym_session.c index 231b1640da..e22dd3600c 100644 --- a/drivers/crypto/qat/qat_sym_session.c +++ b/drivers/crypto/qat/qat_sym_session.c @@ -1196,6 +1196,9 @@ static int partial_hash_compute(enum icp_qat_hw_auth_algo hash_alg, uint64_t *hash_state_out_be64; int i; + /* Initialize to avoid gcc warning */ + memset(digest, 0, sizeof(digest)); + digest_size = qat_hash_get_digest_size(hash_alg); if (digest_size <= 0) return -EFAULT; -- 2.25.1