85 lines
2.5 KiB
Diff
85 lines
2.5 KiB
Diff
From fb3715e15d70b089e6be7735ebae9aa764dc40d3 Mon Sep 17 00:00:00 2001
|
|
From: Guodong Xu <guodong.xu@linaro.org>
|
|
Date: Wed, 6 Sep 2023 17:53:39 +0800
|
|
Subject: [PATCH 33/48] uadk_provider: handle the async_poll_task_free in
|
|
provider teardown
|
|
|
|
Previously, async_poll_task_free() is registered as part of OPENSSL_atexit.
|
|
However, in the dynamic loading scenario, after uadk_provider is unloaded,
|
|
the function entry of async_poll_task_free() is not valid any more. Calling
|
|
it as part of OPENSSL_cleanup() (who calls all _atexit handlers) generates
|
|
a Segmentation Fault.
|
|
|
|
Since this async_poll_task_free() is about uadk_provider's resources free,
|
|
so move the call of this functiion into provider teardown. This ensures
|
|
this function is called before uadk_provider module's destruction.
|
|
|
|
Signed-off-by: Guodong Xu <guodong.xu@linaro.org>
|
|
---
|
|
src/uadk_async.c | 4 +---
|
|
src/uadk_async.h | 1 +
|
|
src/uadk_engine_init.c | 2 ++
|
|
src/uadk_prov_init.c | 1 +
|
|
4 files changed, 5 insertions(+), 3 deletions(-)
|
|
|
|
diff --git a/src/uadk_async.c b/src/uadk_async.c
|
|
index dfac1cb..c46976c 100644
|
|
--- a/src/uadk_async.c
|
|
+++ b/src/uadk_async.c
|
|
@@ -112,7 +112,7 @@ int async_clear_async_event_notification(void)
|
|
return 1;
|
|
}
|
|
|
|
-static void async_poll_task_free(void)
|
|
+void async_poll_task_free(void)
|
|
{
|
|
int error;
|
|
struct async_poll_task *task;
|
|
@@ -381,8 +381,6 @@ int async_module_init(void)
|
|
goto err;
|
|
|
|
poll_queue.thread_id = thread_id;
|
|
- OPENSSL_atexit(async_poll_task_free);
|
|
-
|
|
return 1;
|
|
|
|
err:
|
|
diff --git a/src/uadk_async.h b/src/uadk_async.h
|
|
index d7a8bb5..9160c98 100644
|
|
--- a/src/uadk_async.h
|
|
+++ b/src/uadk_async.h
|
|
@@ -78,4 +78,5 @@ int async_module_init(void);
|
|
int async_wake_job(ASYNC_JOB *job);
|
|
void async_free_poll_task(int id, bool is_cb);
|
|
int async_get_free_task(int *id);
|
|
+void async_poll_task_free(void);
|
|
#endif
|
|
diff --git a/src/uadk_engine_init.c b/src/uadk_engine_init.c
|
|
index 0a9e3e6..e2aa392 100644
|
|
--- a/src/uadk_engine_init.c
|
|
+++ b/src/uadk_engine_init.c
|
|
@@ -220,6 +220,8 @@ static int uadk_destroy(ENGINE *e)
|
|
if (uadk_dh)
|
|
uadk_e_destroy_dh();
|
|
|
|
+ async_poll_task_free();
|
|
+
|
|
pthread_mutex_lock(&uadk_engine_mutex);
|
|
uadk_inited = 0;
|
|
pthread_mutex_unlock(&uadk_engine_mutex);
|
|
diff --git a/src/uadk_prov_init.c b/src/uadk_prov_init.c
|
|
index 57910ac..af22dfa 100644
|
|
--- a/src/uadk_prov_init.c
|
|
+++ b/src/uadk_prov_init.c
|
|
@@ -115,6 +115,7 @@ static void p_teardown(void *provctx)
|
|
uadk_prov_destroy_cipher();
|
|
OPENSSL_free(ctx);
|
|
OSSL_PROVIDER_unload(prov);
|
|
+ async_poll_task_free();
|
|
}
|
|
|
|
static const OSSL_DISPATCH p_test_table[] = {
|
|
--
|
|
2.25.1
|
|
|