]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
efi/tpm: Fix memory leak in grub_tpm1/2_log_event()
authorTianjia Zhang <tianjia.zhang@linux.alibaba.com>
Mon, 23 Mar 2020 11:52:51 +0000 (19:52 +0800)
committerDaniel Kiper <daniel.kiper@oracle.com>
Tue, 31 Mar 2020 10:16:32 +0000 (12:16 +0200)
The memory requested for the event is not released here,
causing memory leaks. This patch fixes this problem.

Signed-off-by: Jia Zhang <zhang.jia@linux.alibaba.com>
Signed-off-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
grub-core/commands/efi/tpm.c

index 32909c192ff09e713bbadbe82c9771800fd101d0..6a6cd0d83c2df04a642fb0f1f8f29e4401f3c464 100644 (file)
@@ -247,6 +247,7 @@ grub_tpm1_log_event (grub_efi_handle_t tpm_handle, unsigned char *buf,
   algorithm = TCG_ALG_SHA;
   status = efi_call_7 (tpm->log_extend_event, tpm, (grub_addr_t) buf, (grub_uint64_t) size,
                       algorithm, event, &eventnum, &lastevent);
+  grub_free (event);
 
   switch (status)
     {
@@ -297,6 +298,7 @@ grub_tpm2_log_event (grub_efi_handle_t tpm_handle, unsigned char *buf,
 
   status = efi_call_5 (tpm->hash_log_extend_event, tpm, 0, (grub_addr_t) buf,
                       (grub_uint64_t) size, event);
+  grub_free (event);
 
   switch (status)
     {