From: Aleksander Gajewski Date: Fri, 10 Feb 2017 09:22:32 +0000 (+0100) Subject: app/crypto-perf: fix uninitialized variable X-Git-Tag: spdx-start~4504 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=48ae81144f32c3b1edf6ef56bf8643cd710333cb;p=dpdk.git app/crypto-perf: fix uninitialized variable This commit ixes 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 Acked-by: Pablo de Lara --- diff --git a/app/test-crypto-perf/main.c b/app/test-crypto-perf/main.c index 634ea5f849..7fbda7a856 100644 --- a/app/test-crypto-perf/main.c +++ b/app/test-crypto-perf/main.c @@ -264,7 +264,7 @@ main(int argc, char **argv) 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 @@ main(int argc, char **argv) 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 @@ main(int argc, char **argv) err: i = 0; RTE_LCORE_FOREACH_SLAVE(lcore_id) { - if (i == nb_cryptodevs) break;