This commit fixes a segfault, that occurs when NULL pointer
is being set to the aad pointer field.

Fixes: a815a04cea05 ("crypto/qat: support symmetric build op request")
Cc: sta...@dpdk.org

Signed-off-by: Arkadiusz Kusztal <arkadiuszx.kusz...@intel.com>
---
 drivers/crypto/qat/dev/qat_crypto_pmd_gens.h | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/crypto/qat/dev/qat_crypto_pmd_gens.h 
b/drivers/crypto/qat/dev/qat_crypto_pmd_gens.h
index eebf2e6eb8..83a6c30218 100644
--- a/drivers/crypto/qat/dev/qat_crypto_pmd_gens.h
+++ b/drivers/crypto/qat/dev/qat_crypto_pmd_gens.h
@@ -881,10 +881,12 @@ enqueue_one_aead_job_gen1(struct qat_sym_session *ctx,
                *(uint8_t *)&cipher_param->u.cipher_IV_array[0] =
                        q - ICP_QAT_HW_CCM_NONCE_OFFSET;
 
-               rte_memcpy((uint8_t *)aad->va +
-                               ICP_QAT_HW_CCM_NONCE_OFFSET,
-                       (uint8_t *)iv->va + ICP_QAT_HW_CCM_NONCE_OFFSET,
-                       ctx->cipher_iv.length);
+               if (ctx->aad_len > 0) {
+                       rte_memcpy((uint8_t *)aad->va +
+                                       ICP_QAT_HW_CCM_NONCE_OFFSET,
+                               (uint8_t *)iv->va + ICP_QAT_HW_CCM_NONCE_OFFSET,
+                               ctx->cipher_iv.length);
+               }
                break;
        default:
                break;
-- 
2.13.6

Reply via email to