From 1ff08b383a59150a193870b3150d5265a03864ed Mon Sep 17 00:00:00 2001 From: Wenkai Lin Date: Thu, 10 Mar 2022 20:03:20 +0800 Subject: [PATCH 35/36] cipher: fix segmentation fault for uadk_e_ctx_init if uadk_e_init_cipher failed, there is no need to alloc cipher session, and alloc session will meet a segmentation fault because sched_init is not set by wd_cipher_init. Signed-off-by: Wenkai Lin --- src/uadk_cipher.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/uadk_cipher.c b/src/uadk_cipher.c index e4595be..d6dd8e8 100644 --- a/src/uadk_cipher.c +++ b/src/uadk_cipher.c @@ -846,15 +846,16 @@ static void uadk_e_ctx_init(EVP_CIPHER_CTX *ctx, struct cipher_priv_ctx *priv) struct sched_params params = {0}; int ret; + priv->req.iv_bytes = EVP_CIPHER_CTX_iv_length(ctx); + priv->req.iv = priv->iv; + ret = uadk_e_init_cipher(); if (unlikely(!ret)) { priv->switch_flag = UADK_DO_SOFT; fprintf(stderr, "uadk failed to init cipher HW!\n"); + return; } - priv->req.iv_bytes = EVP_CIPHER_CTX_iv_length(ctx); - priv->req.iv = priv->iv; - /* * The internal RR scheduler used by environment variables, * the cipher algorithm does not distinguish between -- 2.24.4