46 lines
1.2 KiB
Diff
46 lines
1.2 KiB
Diff
From fef65630b7470bbb6f4fbecd946247fe8ba09027 Mon Sep 17 00:00:00 2001
|
|
From: Wenkai Lin <linwenkai6@hisilicon.com>
|
|
Date: Thu, 9 Nov 2023 11:23:39 +0800
|
|
Subject: [PATCH 57/63] cipher: fix uadk_e_destroy_cipher memory leak
|
|
|
|
Fix an issue where hardware resources are not released
|
|
and locks are not destroyed.
|
|
|
|
Signed-off-by: Wenkai Lin <linwenkai6@hisilicon.com>
|
|
---
|
|
src/uadk_cipher.c | 18 ++++++++++++++++++
|
|
1 file changed, 18 insertions(+)
|
|
|
|
diff --git a/src/uadk_cipher.c b/src/uadk_cipher.c
|
|
index 73be09d..63cc738 100644
|
|
--- a/src/uadk_cipher.c
|
|
+++ b/src/uadk_cipher.c
|
|
@@ -996,6 +996,24 @@ static void destroy_cipher(struct engine_cipher_info *info, int num)
|
|
|
|
void uadk_e_destroy_cipher(struct engine_cipher_info *info, int num)
|
|
{
|
|
+ __u32 i;
|
|
+ int ret;
|
|
+
|
|
+ if (g_cipher_engine.pid == getpid()) {
|
|
+ ret = uadk_e_is_env_enabled("cipher");
|
|
+ if (ret == ENV_ENABLED) {
|
|
+ wd_cipher_env_uninit();
|
|
+ } else {
|
|
+ wd_cipher_uninit();
|
|
+ for (i = 0; i < g_cipher_engine.ctx_cfg.ctx_num; i++)
|
|
+ wd_release_ctx(g_cipher_engine.ctx_cfg.ctxs[i].ctx);
|
|
+ free(g_cipher_engine.ctx_cfg.ctxs);
|
|
+ }
|
|
+ g_cipher_engine.pid = 0;
|
|
+ }
|
|
+
|
|
+ pthread_spin_destroy(&g_cipher_engine.lock);
|
|
+
|
|
destroy_cipher(info, num);
|
|
}
|
|
|
|
--
|
|
2.25.1
|
|
|