app/crypto-perf: fix uninitialized variable
authorAleksander Gajewski <aleksanderx.gajewski@intel.com>
Fri, 10 Feb 2017 09:22:32 +0000 (10:22 +0100)
committerPablo de Lara <pablo.de.lara.guarch@intel.com>
Fri, 10 Feb 2017 15:05:22 +0000 (16:05 +0100)
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 <aleksanderx.gajewski@intel.com>
Acked-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
app/test-crypto-perf/main.c

index 634ea5f..7fbda7a 100644 (file)
@@ -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;