[dpdk-dev] [PATCH] app/test-crypto-perf: fix uninitialized scalar variable
De Lara Guarch, Pablo
pablo.de.lara.guarch at intel.com
Thu Feb 9 23:55:15 CET 2017
> -----Original Message-----
> From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Aleksander
> Gajewski
> Sent: Tuesday, February 07, 2017 9:22 AM
> To: Doherty, Declan
> Cc: dev at dpdk.org; Gajewski, AleksanderX
> Subject: [dpdk-dev] [PATCH] app/test-crypto-perf: fix uninitialized scalar
> variable
>
> 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.
>
> Coverity issue: 141073
> Fixes: f8be1786b1b8 ("app/crypto-perf: introduce performance test
> application")
>
> Signed-off-by: Aleksander Gajewski <aleksanderx.gajewski at intel.com>
> ---
> app/test-crypto-perf/main.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/app/test-crypto-perf/main.c b/app/test-crypto-perf/main.c
> index 6c128d8..035021a 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 };
>
> --
> 1.9.1
Actually, this fix is incomplete.
In a few lines below, we have these lines:
nb_cryptodevs = cperf_initialize_cryptodev(&opts, enabled_cdevs);
if (nb_cryptodevs < 1) {
RTE_LOG(ERR, USER1, "Failed to initialise requested crypto "
"device type\n");
goto err;
}
If cperf_initialize_cryptodev() returns -EINVAL, then, nb_cryptodevs will be negative,
which shouldn't be when going to err label.
I think "nb_cryptodevs = 0 " is necessary inside this conditional, before jumping to err.
Thanks,
Pablo
More information about the dev
mailing list