diff mbox series

[API-NEXT,v1,1/2] validation: crypto: clean shutdown in case pkt allocation failed

Message ID 1514458808-9218-2-git-send-email-odpbot@yandex.ru
State New
Headers show
Series [API-NEXT,v1,1/2] validation: crypto: clean shutdown in case pkt allocation failed | expand

Commit Message

Github ODP bot Dec. 28, 2017, 11 a.m. UTC
From: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>


Provide clean shutdown path for the case of odp_packet_alloc() returning
ODP_PACKET_INVALID.

Signed-off-by: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>

---
/** Email created from pull request 376 (lumag:test-fixes)
 ** https://github.com/Linaro/odp/pull/376
 ** Patch: https://github.com/Linaro/odp/pull/376.patch
 ** Base sha: 68735b312926a44ddf42f9ecf96a0badd941a247
 ** Merge commit sha: c3ae2320e846c56ecc6040c63336b9e30de0beee
 **/
 test/validation/api/crypto/odp_crypto_test_inp.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/test/validation/api/crypto/odp_crypto_test_inp.c b/test/validation/api/crypto/odp_crypto_test_inp.c
index f1da6989c..821bdc7e4 100644
--- a/test/validation/api/crypto/odp_crypto_test_inp.c
+++ b/test/validation/api/crypto/odp_crypto_test_inp.c
@@ -458,6 +458,8 @@  static void alg_test(odp_crypto_op_t op,
 	odp_packet_t pkt = odp_packet_alloc(suite_context.pool,
 					    ref->length + ref->digest_length);
 	CU_ASSERT(pkt != ODP_PACKET_INVALID);
+	if (pkt == ODP_PACKET_INVALID)
+		goto cleanup;
 
 	for (iteration = NORMAL_TEST; iteration < MAX_TEST; iteration++) {
 		/* checking against wrong digest is meaningless for NULL digest
@@ -523,10 +525,11 @@  static void alg_test(odp_crypto_op_t op,
 		}
 	}
 
+	odp_packet_free(pkt);
+
+cleanup:
 	rc = odp_crypto_session_destroy(session);
 	CU_ASSERT(!rc);
-
-	odp_packet_free(pkt);
 }
 
 /**