summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Jones <pjones@redhat.com>2021-08-03 17:18:25 -0400
committerPeter Jones <pjones@redhat.com>2021-09-07 17:05:04 -0400
commit11080efc7416c342b8f26ddb6ea1e8ef21026ddc (patch)
tree8801ab58cbf0269b3c8a444f44c3d01f502a5d81
parentcae5e2f7c100bc9e8f07de62353021d6737a50ee (diff)
downloadefi-boot-shim-11080efc7416c342b8f26ddb6ea1e8ef21026ddc.tar.gz
efi-boot-shim-11080efc7416c342b8f26ddb6ea1e8ef21026ddc.zip
tpm: free measureddata when SHIM_UNIT_TEST is set
Keep from cluttering up valgrind with allocations that aren't part of the tested info (yet). Signed-off-by: Peter Jones <pjones@redhat.com>
-rw-r--r--tpm.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/tpm.c b/tpm.c
index 808e0444..5af5f173 100644
--- a/tpm.c
+++ b/tpm.c
@@ -353,3 +353,25 @@ fallback_should_prefer_reset(void)
return EFI_NOT_FOUND;
return EFI_SUCCESS;
}
+
+#ifdef SHIM_UNIT_TEST
+static void DESTRUCTOR
+tpm_clean_up_measurements(void)
+{
+ for (UINTN i = 0; i < measuredcount; i++) {
+ VARIABLE_RECORD *vr = &measureddata[i];
+
+ if (vr->VariableName)
+ FreePool(vr->VariableName);
+ if (vr->VendorGuid)
+ FreePool(vr->VendorGuid);
+ if (vr->Data)
+ FreePool(vr->Data);
+ }
+ if (measureddata)
+ FreePool(measureddata);
+
+ measuredcount = 0;
+ measureddata = NULL;
+}
+#endif