mirror of https://github.com/wolfSSL/wolfTPM.git
F-12707 - Clean up wolfCrypt only when its init succeeded
parent
efa68e4acf
commit
7f02facf89
|
|
@ -40,6 +40,7 @@ int FWTPM_Init(FWTPM_CTX* ctx)
|
|||
{
|
||||
int rc;
|
||||
int rngInit = 0;
|
||||
int wcInit = 0;
|
||||
FWTPM_NV_HAL savedNvHal;
|
||||
struct FWTPM_CLOCK_HAL_S savedClockHal;
|
||||
#ifndef FWTPM_NO_PP
|
||||
|
|
@ -96,6 +97,7 @@ int FWTPM_Init(FWTPM_CTX* ctx)
|
|||
/* Initialize wolfCrypt RNG */
|
||||
rc = wolfCrypt_Init();
|
||||
if (rc == 0) {
|
||||
wcInit = 1;
|
||||
rc = wc_InitRng(&ctx->rng);
|
||||
if (rc == 0) {
|
||||
rngInit = 1;
|
||||
|
|
@ -141,8 +143,10 @@ int FWTPM_Init(FWTPM_CTX* ctx)
|
|||
if (rngInit) {
|
||||
wc_FreeRng(&ctx->rng);
|
||||
}
|
||||
if (wcInit) {
|
||||
wolfCrypt_Cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue