From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id 73F97282 for ; Fri, 10 Feb 2017 10:25:42 +0100 (CET) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga104.jf.intel.com with ESMTP; 10 Feb 2017 01:25:39 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.35,140,1484035200"; d="scan'208";a="1105577635" Received: from gklab-246-020.igk.intel.com (HELO Sent) ([10.217.246.20]) by fmsmga001.fm.intel.com with SMTP; 10 Feb 2017 01:25:36 -0800 Received: by Sent (sSMTP sendmail emulation); Fri, 10 Feb 2017 10:22:34 +0100 From: Aleksander Gajewski To: declan.doherty@intel.com Cc: dev@dpdk.org, pablo.de.lara.guarch@intel.com, Aleksander Gajewski Date: Fri, 10 Feb 2017 10:22:32 +0100 Message-Id: <1486718552-3741-1-git-send-email-aleksanderx.gajewski@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1486459306-11496-1-git-send-email-aleksanderx.gajewski@intel.com> References: <1486459306-11496-1-git-send-email-aleksanderx.gajewski@intel.com> Subject: [dpdk-dev] [PATCH v2] app/test-crypto-perf: fix uninitialized scalar 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: , X-List-Received-Date: Fri, 10 Feb 2017 09:25:42 -0000 Fix problem with uninitialized nb_cryptodevs variable by initialize it with 0 value. Program could jump to err label without running cperf_initialize_cryptodev() function. Also assign 0 value to nb_cryptodevs after cperf_initialize_cryptodev() when value is negative. Coverity issue: 141073 Fixes: f8be1786b1b8 ("app/crypto-perf: introduce performance test application") Signed-off-by: Aleksander Gajewski --- v2: * When nb_cryptodevs is negative after cperf_initialize_cryptodev() assign 0 value to it. --- app/test-crypto-perf/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/test-crypto-perf/main.c b/app/test-crypto-perf/main.c index 6c128d8..08bf5e4 100644 --- a/app/test-crypto-perf/main.c +++ b/app/test-crypto-perf/main.c @@ -264,7 +264,7 @@ void *ctx[RTE_MAX_LCORE] = { }; - int nb_cryptodevs; + int nb_cryptodevs = 0; uint8_t cdev_id, i; uint8_t enabled_cdevs[RTE_CRYPTO_MAX_DEVS] = { 0 }; @@ -300,6 +300,7 @@ if (nb_cryptodevs < 1) { RTE_LOG(ERR, USER1, "Failed to initialise requested crypto " "device type\n"); + nb_cryptodevs = 0; goto err; } @@ -397,7 +398,6 @@ err: i = 0; RTE_LCORE_FOREACH_SLAVE(lcore_id) { - if (i == nb_cryptodevs) break; -- 1.9.1 -------------------------------------------------------------------- Intel Technology Poland sp. z o.o. ul. Slowackiego 173 | 80-298 Gdansk | Sad Rejonowy Gdansk Polnoc | VII Wydzial Gospodarczy Krajowego Rejestru Sadowego - KRS 101882 | NIP 957-07-52-316 | Kapital zakladowy 200.000 PLN. Ta wiadomosc wraz z zalacznikami jest przeznaczona dla okreslonego adresata i moze zawierac informacje poufne. W razie przypadkowego otrzymania tej wiadomosci, prosimy o powiadomienie nadawcy oraz trwale jej usuniecie; jakiekolwiek przegladanie lub rozpowszechnianie jest zabronione. This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). If you are not the intended recipient, please contact the sender and delete all copies; any review or distribution by others is strictly prohibited.