From e716ff141b967986d35fc65c59ab0e03015dce48 Mon Sep 17 00:00:00 2001 From: houmingyong Date: Thu, 13 Jan 2022 10:24:23 +0800 Subject: [PATCH] destroy rwlock when create enclave failed Conflict:NA Reference:https://gitee.com/openeuler/secGear/commit/cb80972c3a60261786d76a2a50ab5ce29b312ebd --- src/host_src/enclave.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/host_src/enclave.c b/src/host_src/enclave.c index 8d6c8a6..e163b58 100644 --- a/src/host_src/enclave.c +++ b/src/host_src/enclave.c @@ -68,6 +68,7 @@ static void error_handle(cc_enclave_t *enclave, void *handle, p_tee_registered r } if (enclave) { + pthread_rwlock_destroy(&enclave->rwlock); explicit_bzero(enclave, sizeof(cc_enclave_t)); } } @@ -192,7 +193,10 @@ cc_enclave_result_t cc_enclave_create(const char *path, enclave_type_t type, uin memset(enclave, 0, sizeof(cc_enclave_t)); if (!check_transform_path(&res, path, &l_path) || !chose_engine_type(&res, type, version, &type_version)) { - goto done; + if (l_path) { + free(l_path); + } + return CC_FAIL; } /* to do: gp support enter enclave debugging */ -- 2.27.0