efi/tpm: Fix memory leak in grub_tpm1/2_log_event()

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>
This commit is contained in:
Tianjia Zhang 2020-03-23 19:52:51 +08:00 committed by Daniel Kiper
parent 5e5a47b8a7
commit 800de4a1d0

View file

@ -247,6 +247,7 @@ grub_tpm1_log_event (grub_efi_handle_t tpm_handle, unsigned char *buf,
algorithm = TCG_ALG_SHA; algorithm = TCG_ALG_SHA;
status = efi_call_7 (tpm->log_extend_event, tpm, (grub_addr_t) buf, (grub_uint64_t) size, status = efi_call_7 (tpm->log_extend_event, tpm, (grub_addr_t) buf, (grub_uint64_t) size,
algorithm, event, &eventnum, &lastevent); algorithm, event, &eventnum, &lastevent);
grub_free (event);
switch (status) 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, status = efi_call_5 (tpm->hash_log_extend_event, tpm, 0, (grub_addr_t) buf,
(grub_uint64_t) size, event); (grub_uint64_t) size, event);
grub_free (event);
switch (status) switch (status)
{ {