crypto/armv8: remove algo lists end
[dpdk.git] / drivers / crypto / armv8 / rte_armv8_pmd.c
index a2b08d8..3f6cb66 100644 (file)
@@ -143,7 +143,8 @@ crypto_chain_order[] = {
        crypto_func_tbl_t *func_tbl =                                   \
                                (crypto_chain_order[(order)])[(cop)];   \
                                                                        \
-       ((*func_tbl)[(calg)][(aalg)][KEYL(keyl)]);              \
+       ((calg >= CRYPTO_CIPHER_MAX) || (aalg >= CRYPTO_AUTH_MAX)) ?    \
+               NULL : ((*func_tbl)[(calg)][(aalg)][KEYL(keyl)]);       \
 })
 
 /*----------------------------------------------------------------------------*/
@@ -188,7 +189,8 @@ crypto_key_sched_dir[] = {
 ({                                                                     \
        crypto_key_sched_tbl_t *ks_tbl = crypto_key_sched_dir[(cop)];   \
                                                                        \
-       ((*ks_tbl)[(calg)][KEYL(keyl)]);                                \
+       (calg >= CRYPTO_CIPHER_MAX) ?                                   \
+               NULL : ((*ks_tbl)[(calg)][KEYL(keyl)]);                 \
 })
 
 /*----------------------------------------------------------------------------*/
@@ -436,7 +438,8 @@ armv8_crypto_set_session_chained_parameters(struct armv8_crypto_session *sess,
                return -ENOTSUP;
        }
 
-       if (unlikely(sess->crypto_func == NULL)) {
+       if (unlikely(sess->crypto_func == NULL ||
+               sess->cipher.key_sched == NULL)) {
                /*
                 * If we got here that means that there must be a bug
                 * in the algorithms selection above. Nevertheless keep
@@ -630,7 +633,7 @@ process_armv8_chained_op(struct armv8_crypto_qp *qp, struct rte_crypto_op *op,
        arg.cipher.key = sess->cipher.key.data;
        /* Acquire combined mode function */
        crypto_func = sess->crypto_func;
-       ARMV8_CRYPTO_ASSERT(crypto_func != NULL);
+       RTE_VERIFY(crypto_func != NULL);
        error = crypto_func(csrc, cdst, clen, asrc, adst, alen, &arg);
        if (error != 0) {
                op->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
@@ -674,8 +677,8 @@ process_op(struct armv8_crypto_qp *qp, struct rte_crypto_op *op,
                memset(op->sym->session, 0,
                        rte_cryptodev_sym_get_existing_header_session_size(
                                op->sym->session));
-               rte_mempool_put(qp->sess_mp, sess);
-               rte_mempool_put(qp->sess_mp_priv, op->sym->session);
+               rte_mempool_put(qp->sess_mp_priv, sess);
+               rte_mempool_put(qp->sess_mp, op->sym->session);
                op->sym->session = NULL;
        }