]> 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 02:15:18 +0000 (22:15 -0400)
lib/isc/pk11.c

index 57bf2a234eb26d4718f298a9945e4fe474eda1a1..cfc5e52074eafdd4596fc731c0cbc31c4e4702ad 100644 (file)
@@ -182,21 +182,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);
@@ -220,7 +219,6 @@ pk11_initialize(isc_mem_t *mctx, const char *engine) {
        }
 
        scan_slots();
-       result = ISC_R_SUCCESS;
  unlock:
        UNLOCK(&sessionlock);
        return (result);