Set 'g_rsa_res.ctx_res' to NULL when init failed. This can avoid repeated source release in uninit in abnormal cases.
Signed-off-by: Zhiqi Song songzhiqi1@huawei.com --- src/uadk_rsa.c | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/src/uadk_rsa.c b/src/uadk_rsa.c index 8669455..bc51e7d 100644 --- a/src/uadk_rsa.c +++ b/src/uadk_rsa.c @@ -818,6 +818,7 @@ static int uadk_e_rsa_init(void) return UADK_E_INIT_SUCCESS;
err_unlock: + g_rsa_res.ctx_res = NULL; pthread_spin_unlock(&g_rsa_res.lock); free(dev); (void)fprintf(stderr, "failed to init rsa(%d)\n", ret); @@ -831,6 +832,9 @@ static void uadk_e_rsa_uninit(void) __u32 i; int ret;
+ if (!ctx_cfg) + return; + if (g_rsa_res.pid == getpid()) { ret = uadk_e_is_env_enabled("rsa"); if (ret == ENV_ENABLED) {