Commit d5cef9cd authored by Mark Andrews's avatar Mark Andrews
Browse files

fix lock order reversal

(cherry picked from commit 2bb4392b)
parent f8853681
...@@ -185,21 +185,20 @@ pk11_mem_put(void *ptr, size_t size) { ...@@ -185,21 +185,20 @@ pk11_mem_put(void *ptr, size_t size) {
isc_result_t isc_result_t
pk11_initialize(isc_mem_t *mctx, const char *engine) { pk11_initialize(isc_mem_t *mctx, const char *engine) {
isc_result_t result; isc_result_t result = ISC_R_SUCCESS;
CK_RV rv; CK_RV rv;
RUNTIME_CHECK(isc_once_do(&once, initialize) == ISC_R_SUCCESS); RUNTIME_CHECK(isc_once_do(&once, initialize) == ISC_R_SUCCESS);
LOCK(&sessionlock);
LOCK(&alloclock); LOCK(&alloclock);
if ((mctx != NULL) && (pk11_mctx == NULL) && (allocsize == 0)) if ((mctx != NULL) && (pk11_mctx == NULL) && (allocsize == 0))
isc_mem_attach(mctx, &pk11_mctx); isc_mem_attach(mctx, &pk11_mctx);
UNLOCK(&alloclock);
if (initialized) { if (initialized) {
UNLOCK(&alloclock); goto unlock;
return (ISC_R_SUCCESS);
} else { } else {
LOCK(&sessionlock);
initialized = true; initialized = true;
UNLOCK(&alloclock);
} }
ISC_LIST_INIT(tokens); ISC_LIST_INIT(tokens);
...@@ -239,7 +238,6 @@ pk11_initialize(isc_mem_t *mctx, const char *engine) { ...@@ -239,7 +238,6 @@ pk11_initialize(isc_mem_t *mctx, const char *engine) {
} }
#endif #endif
#endif /* PKCS11CRYPTO */ #endif /* PKCS11CRYPTO */
result = ISC_R_SUCCESS;
unlock: unlock:
UNLOCK(&sessionlock); UNLOCK(&sessionlock);
return (result); return (result);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment