Skip to contentSkip to conversation

app/test-crypto-perf: fix uninitialized scalar variable

PATCH Superseded Aleksander Gajewski 2 participants 5 messages Feb 7, 2017 – Feb 10, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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")

---
 app/test-crypto-perf/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
app/test-crypto-perf/main.c +1 -1
index 6c128d8..035021a 100644
@@ -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 };
 
Signature · 11 lines
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.
#1 lore raw
Quoted 38 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Aleksander Gajewski
Sent: Tuesday, February 07, 2017 9:22 AM
To: Doherty, Declan
Cc: [email protected]; 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")

---
 app/test-crypto-perf/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
app/test-crypto-perf/main.c +1 -2
index 6c128d8..035021a 100644
@@ -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 };
 
--
Quoted 1 line

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

#2 lore raw

PATCH v2 1/1 app/test-crypto-perf: fix uninitialized scalar variable

In reply to Aleksander Gajewski

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")

---
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(-)
app/test-crypto-perf/main.c +2 -2
index 6c128d8..08bf5e4 100644
@@ -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;
 
Signature · 11 lines
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.
Acked-by on v2 1/1
#3 lore raw
Quoted 15 lines

-----Original Message-----
From: Gajewski, AleksanderX
Sent: Friday, February 10, 2017 9:23 AM
To: Doherty, Declan
Cc: [email protected]; De Lara Guarch, Pablo; Gajewski, AleksanderX
Subject: [PATCH v2] 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. Also assign 0 value to nb_cryptodevs after cperf_initialize_cryptodev() when value is negative.

Quoted 5 lines

Coverity issue: 141073

Fixes f8be1786b1b8 ("app/crypto-perf: introduce performance test

application")

#4 lore raw
Quoted 26 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of De Lara Guarch, Pablo
Sent: Friday, February 10, 2017 9:47 AM
To: Gajewski, AleksanderX; Doherty, Declan
Cc: [email protected]
Subject: Re: [dpdk-dev] [PATCH v2] app/test-crypto-perf: fix uninitialized scalar variable

Quoted 13 lines

-----Original Message-----
From: Gajewski, AleksanderX
Sent: Friday, February 10, 2017 9:23 AM
To: Doherty, Declan
Cc: [email protected]; De Lara Guarch, Pablo; Gajewski, AleksanderX
Subject: [PATCH v2] 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. Also assign 0 value to nb_cryptodevs after cperf_initialize_cryptodev() when value is negative.

Quoted 7 lines
Quoted 5 lines

Coverity issue: 141073

Fixes f8be1786b1b8 ("app/crypto-perf: introduce performance test

application")

Applied to dpdk-next-crypto.
Thanks,

Pablo