Fix no `WOLFSSL_MUTEX_INITIALIZER` case.

pull/410/head
David Garske 2025-04-29 22:10:00 -07:00
parent d27306b1c9
commit ac800d3820
1 changed files with 6 additions and 4 deletions

View File

@ -493,8 +493,9 @@ static inline int TPM2_WolfCrypt_Init(void)
if (rc == 0)
rc = wc_SetSeed_Cb(wc_GenerateSeed);
#endif
#ifndef WOLFSSL_MUTEX_INITIALIZER
wc_InitMutex(&gHwMutex);
#if !defined(WOLFTPM_NO_LOCK) && !defined(SINGLE_THREADED) && \
!defined(WOLFSSL_MUTEX_INITIALIZER)
wc_InitMutex(&gHwLock);
#endif
}
gWolfCryptRefCount++;
@ -693,8 +694,9 @@ TPM_RC TPM2_Cleanup(TPM2_CTX* ctx)
if (gWolfCryptRefCount < 0)
gWolfCryptRefCount = 0;
if (gWolfCryptRefCount == 0) {
#ifndef WOLFSSL_MUTEX_INITIALIZER
wc_FreeMutex(&gHwMutex);
#if !defined(WOLFTPM_NO_LOCK) && !defined(SINGLE_THREADED) && \
!defined(WOLFSSL_MUTEX_INITIALIZER)
wc_FreeMutex(&gHwLock);
#endif
wolfCrypt_Cleanup();
}