Skip to content

Commit

Permalink
efi_selftest: error handling in efi_selftest_tcg2
Browse files Browse the repository at this point in the history
If memory allocation fails, write an error message.

Signed-off-by: Heinrich Schuchardt <[email protected]>
  • Loading branch information
xypron committed May 3, 2022
1 parent 0db8221 commit c900a42
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/efi_selftest/efi_selftest_tcg2.c
Original file line number Diff line number Diff line change
Expand Up @@ -631,8 +631,10 @@ static int efi_st_tcg2_setup(const efi_handle_t img_handle,
sizeof(struct efi_tcg2_event) +
sizeof(struct uefi_image_load_event),
(void **)&efi_tcg2_event);
if (!efi_tcg2_event)
if (ret != EFI_SUCCESS) {
efi_st_error("Out of memory\n");
return EFI_ST_FAILURE;
}

efi_tcg2_event->size = sizeof(struct efi_tcg2_event) +
sizeof(struct uefi_image_load_event);
Expand All @@ -659,8 +661,10 @@ static int efi_st_tcg2_setup(const efi_handle_t img_handle,
(EFI_TCG2_MAX_PCR_INDEX + 1) *
TPM2_SHA256_DIGEST_SIZE,
(void **)&pcrs);
if (!pcrs)
if (ret != EFI_SUCCESS) {
efi_st_error("Out of memory\n");
return EFI_ST_FAILURE;
}

boottime->set_mem(pcrs, (EFI_TCG2_MAX_PCR_INDEX + 1) * TPM2_SHA256_DIGEST_SIZE, 0);

Expand Down

0 comments on commit c900a42

Please sign in to comment.