tpm2: Fix memory leak by freeing KDF context

Fix a memory leak by freeing the KDF context after usage.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
This commit is contained in:
Stefan Berger 2025-08-28 08:00:44 -04:00
parent 297420e632
commit 33d83201bd

View File

@ -1131,7 +1131,7 @@ UINT16 OSSLCryptKDFe(TPM_ALG_ID hashAlg, // IN: hash algorithm used in HMAC
size_t buffer_size = 0;
UINT16 generated = 0;
size_t offset = 0;
EVP_KDF_CTX *ctx;
EVP_KDF_CTX *ctx = NULL;
EVP_KDF *kdf;
char *buffer;
INT16 bytes; // number of bytes to generate
@ -1197,6 +1197,7 @@ UINT16 OSSLCryptKDFe(TPM_ALG_ID hashAlg, // IN: hash algorithm used in HMAC
generated = bytes;
out:
EVP_KDF_CTX_free(ctx);
EVP_KDF_free(kdf);
free(buffer);