]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
fix lock order reversal
authorMark Andrews <marka@isc.org>
Thu, 2 Aug 2018 05:34:31 +0000 (15:34 +1000)
committerMark Andrews <marka@isc.org>
Tue, 21 Aug 2018 03:33:37 +0000 (13:33 +1000)
(cherry picked from commit 2bb4392bb3de0b10f9e31f14e4f871f6863cfc2e)

lib/isc/pk11.c

index 371e168e48016eea5066fc31c05e714d6a17d061..28a9b9f920512fe0f59498b34d61d92250b7f0e6 100644 (file)
@@ -185,21 +185,20 @@ pk11_mem_put(void *ptr, size_t size) {
 
 isc_result_t
 pk11_initialize(isc_mem_t *mctx, const char *engine) {
-       isc_result_t result;
+       isc_result_t result = ISC_R_SUCCESS;
        CK_RV rv;
 
        RUNTIME_CHECK(isc_once_do(&once, initialize) == ISC_R_SUCCESS);
 
+       LOCK(&sessionlock);
        LOCK(&alloclock);
        if ((mctx != NULL) && (pk11_mctx == NULL) && (allocsize == 0))
                isc_mem_attach(mctx, &pk11_mctx);
+       UNLOCK(&alloclock);
        if (initialized) {
-               UNLOCK(&alloclock);
-               return (ISC_R_SUCCESS);
+               goto unlock;
        } else {
-               LOCK(&sessionlock);
                initialized = true;
-               UNLOCK(&alloclock);
        }
 
        ISC_LIST_INIT(tokens);
@@ -239,7 +238,6 @@ pk11_initialize(isc_mem_t *mctx, const char *engine) {
        }
 #endif
 #endif /* PKCS11CRYPTO */
-       result = ISC_R_SUCCESS;
  unlock:
        UNLOCK(&sessionlock);
        return (result);