From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8A57DA0555; Wed, 19 Feb 2020 01:23:09 +0100 (CET) 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