Merge pull request #412 from dgarske/bench_cleanup

Fix issue with possible handle leak in bench example
pull/395/head
Eric Blankenhorn 2025-05-05 15:13:58 -05:00 committed by GitHub
commit 91ea3684b5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 2 deletions

View File

@ -147,6 +147,7 @@ static int bench_sym_hash(WOLFTPM2_DEV* dev, const char* desc, int algo,
bench_stats_sym_finish(desc, count, inSz, start);
exit:
wolfTPM2_UnloadHandle(dev, &hash.handle);
return rc;
}
@ -185,7 +186,6 @@ static int bench_sym_aes(WOLFTPM2_DEV* dev, WOLFTPM2_KEY* storageKey,
bench_stats_sym_finish(desc, count, inOutSz, start);
exit:
wolfTPM2_UnloadHandle(dev, &aesKey.handle);
return rc;
}
@ -489,14 +489,15 @@ int TPM2_Wrapper_BenchArgs(void* userCtx, int argc, char *argv[])
if (rc != 0) goto exit;
exit:
if (rc != 0) {
printf("Failure 0x%x: %s\n", rc, wolfTPM2_GetRCString(rc));
}
/* Cleanup all handles */
wolfTPM2_UnloadHandle(&dev, &rsaKey.handle);
wolfTPM2_UnloadHandle(&dev, &eccKey.handle);
wolfTPM2_UnloadHandle(&dev, &tpmSession.handle);
wolfTPM2_UnloadHandle(&dev, &storageKey.handle);
wolfTPM2_Cleanup(&dev);