From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.7 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 69699C34031 for ; Wed, 19 Feb 2020 00:23:10 +0000 (UTC) Received: from dpdk.org (dpdk.org [92.243.14.124]) by mail.kernel.org (Postfix) with ESMTP id 1B118208E4 for ; Wed, 19 Feb 2020 00:23:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1B118208E4 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dev-bounces@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id EA72C1C045; Wed, 19 Feb 2020 01:23:08 +0100 (CET) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id E4D161C038 for ; Wed, 19 Feb 2020 01:23:06 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Feb 2020 16:23:05 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,458,1574150400"; d="scan'208";a="268966973" Received: from sivswdev08.ir.intel.com ([10.237.217.47]) by fmsmga002.fm.intel.com with ESMTP; 18 Feb 2020 16:23:04 -0800 From: Konstantin Ananyev To: dev@dpdk.org Cc: akhil.goyal@nxp.com, Konstantin Ananyev Date: Wed, 19 Feb 2020 00:23:02 +0000 Message-Id: <20200219002302.1131-1-konstantin.ananyev@intel.com> X-Mailer: git-send-email 2.18.0 Subject: [dpdk-dev] [PATCH] ipsec: fix use of uninitialized variable X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Defects reported by coverity scan uninit_use_in_call: Using uninitialized element of array clen when calling cpu_crypto_bulk. Coverity issue: 354233, 354234 Fixes: 957394f72658 ("ipsec: support CPU crypto mode") Signed-off-by: Konstantin Ananyev --- lib/librte_ipsec/esp_inb.c | 4 +++- lib/librte_ipsec/esp_outb.c | 4 +++- lib/librte_ipsec/misc.h | 3 ++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/librte_ipsec/esp_inb.c b/lib/librte_ipsec/esp_inb.c index 7b8ab81f6..96eec0131 100644 --- a/lib/librte_ipsec/esp_inb.c +++ b/lib/librte_ipsec/esp_inb.c @@ -737,7 +737,9 @@ cpu_inb_pkt_prepare(const struct rte_ipsec_session *ss, move_bad_mbufs(mb, dr, num, num - k); /* convert mbufs to iovecs and do actual crypto/auth processing */ - cpu_crypto_bulk(ss, sa->cofs, mb, iv, aad, dgst, l4ofs, clen, k); + if (k != 0) + cpu_crypto_bulk(ss, sa->cofs, mb, iv, aad, dgst, + l4ofs, clen, k); return k; } diff --git a/lib/librte_ipsec/esp_outb.c b/lib/librte_ipsec/esp_outb.c index b6d9cbe98..fb9d5864c 100644 --- a/lib/librte_ipsec/esp_outb.c +++ b/lib/librte_ipsec/esp_outb.c @@ -502,7 +502,9 @@ cpu_outb_pkt_prepare(const struct rte_ipsec_session *ss, move_bad_mbufs(mb, dr, n, n - k); /* convert mbufs to iovecs and do actual crypto/auth processing */ - cpu_crypto_bulk(ss, sa->cofs, mb, iv, aad, dgst, l4ofs, clen, k); + if (k != 0) + cpu_crypto_bulk(ss, sa->cofs, mb, iv, aad, dgst, + l4ofs, clen, k); return k; } diff --git a/lib/librte_ipsec/misc.h b/lib/librte_ipsec/misc.h index 53c0457af..771602950 100644 --- a/lib/librte_ipsec/misc.h +++ b/lib/librte_ipsec/misc.h @@ -106,7 +106,8 @@ mbuf_cut_seg_ofs(struct rte_mbuf *mb, struct rte_mbuf *ms, uint32_t ofs, } /* - * process packets using sync crypto engine + * process packets using sync crypto engine. + * expects *num* to be greater then zero. */ static inline void cpu_crypto_bulk(const struct rte_ipsec_session *ss, -- 2.17.1