test/crypto: fix session init failure for wireless case
authorHemant Agrawal <hemant.agrawal@nxp.com>
Wed, 17 Jul 2019 16:22:41 +0000 (21:52 +0530)
committerAkhil Goyal <akhil.goyal@nxp.com>
Fri, 19 Jul 2019 12:43:07 +0000 (14:43 +0200)
This patch add the support to handle the failure in session
create for wireless related cases. Else it will cause
segment fault due to I/O on un-initialized sessions.

Fixes: b3bbd9e5f2659 ("cryptodev: support device independent sessions")
Cc: stable@dpdk.org
Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>
Acked-by: Akhil Goyal <akhil.goyal@nxp.com>
app/test/test_cryptodev.c

index c822164..4197feb 100644 (file)
@@ -2377,6 +2377,7 @@ create_wireless_algo_hash_session(uint8_t dev_id,
        enum rte_crypto_auth_algorithm algo)
 {
        uint8_t hash_key[key_len];
+       int status;
 
        struct crypto_testsuite_params *ts_params = &testsuite_params;
        struct crypto_unittest_params *ut_params = &unittest_params;
@@ -2399,9 +2400,10 @@ create_wireless_algo_hash_session(uint8_t dev_id,
        ut_params->sess = rte_cryptodev_sym_session_create(
                        ts_params->session_mpool);
 
-       rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
+       status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
                        &ut_params->auth_xform,
                        ts_params->session_priv_mpool);
+       TEST_ASSERT_EQUAL(status, 0, "session init failed");
        TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
        return 0;
 }
@@ -2414,7 +2416,7 @@ create_wireless_algo_cipher_session(uint8_t dev_id,
                        uint8_t iv_len)
 {
        uint8_t cipher_key[key_len];
-
+       int status;
        struct crypto_testsuite_params *ts_params = &testsuite_params;
        struct crypto_unittest_params *ut_params = &unittest_params;
 
@@ -2437,9 +2439,10 @@ create_wireless_algo_cipher_session(uint8_t dev_id,
        ut_params->sess = rte_cryptodev_sym_session_create(
                        ts_params->session_mpool);
 
-       rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
+       status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
                        &ut_params->cipher_xform,
                        ts_params->session_priv_mpool);
+       TEST_ASSERT_EQUAL(status, 0, "session init failed");
        TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
        return 0;
 }
@@ -2517,6 +2520,7 @@ create_wireless_algo_cipher_auth_session(uint8_t dev_id,
 
 {
        uint8_t cipher_auth_key[key_len];
+       int status;
 
        struct crypto_testsuite_params *ts_params = &testsuite_params;
        struct crypto_unittest_params *ut_params = &unittest_params;
@@ -2554,10 +2558,11 @@ create_wireless_algo_cipher_auth_session(uint8_t dev_id,
        ut_params->sess = rte_cryptodev_sym_session_create(
                        ts_params->session_mpool);
 
-       rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
+       status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
                        &ut_params->cipher_xform,
                        ts_params->session_priv_mpool);
 
+       TEST_ASSERT_EQUAL(status, 0, "session init failed");
        TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
        return 0;
 }
@@ -2572,6 +2577,7 @@ create_wireless_cipher_auth_session(uint8_t dev_id,
 {
        const uint8_t key_len = tdata->key.len;
        uint8_t cipher_auth_key[key_len];
+       int status;
 
        struct crypto_testsuite_params *ts_params = &testsuite_params;
        struct crypto_unittest_params *ut_params = &unittest_params;
@@ -2614,10 +2620,11 @@ create_wireless_cipher_auth_session(uint8_t dev_id,
        ut_params->sess = rte_cryptodev_sym_session_create(
                        ts_params->session_mpool);
 
-       rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
+       status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
                        &ut_params->cipher_xform,
                        ts_params->session_priv_mpool);
 
+       TEST_ASSERT_EQUAL(status, 0, "session init failed");
        TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
        return 0;
 }
@@ -2643,7 +2650,7 @@ create_wireless_algo_auth_cipher_session(uint8_t dev_id,
                uint8_t cipher_iv_len)
 {
        uint8_t auth_cipher_key[key_len];
-
+       int status;
        struct crypto_testsuite_params *ts_params = &testsuite_params;
        struct crypto_unittest_params *ut_params = &unittest_params;
 
@@ -2677,10 +2684,10 @@ create_wireless_algo_auth_cipher_session(uint8_t dev_id,
        ut_params->sess = rte_cryptodev_sym_session_create(
                        ts_params->session_mpool);
 
-       rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
+       status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
                        &ut_params->auth_xform,
                        ts_params->session_priv_mpool);
-
+       TEST_ASSERT_EQUAL(status, 0, "session init failed");
        TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
 
        return 0;