[SeaBIOS] [PATCH 3/7] tpm: Move error recovery from tpm_extend_acpi_log() to only caller
Kevin O'Connor
kevin at koconnor.net
Sun Nov 22 18:20:58 CET 2015
Move tpm state checking and error handling from tpm_extend_acpi_log()
to its only caller hash_log_event(). This makes tpm_extend_acpi_log()
specific to just ACPI table handling.
Signed-off-by: Kevin O'Connor <kevin at koconnor.net>
---
src/tcgbios.c | 22 ++++++++--------------
1 file changed, 8 insertions(+), 14 deletions(-)
diff --git a/src/tcgbios.c b/src/tcgbios.c
index 7877840..88652fe 100644
--- a/src/tcgbios.c
+++ b/src/tcgbios.c
@@ -280,8 +280,6 @@ reset_acpi_log(void)
tpm_state.entry_count = 0;
}
-static void tpm_set_failure(void);
-
/*
* Extend the ACPI log with the given entry by copying the
* entry data into the log.
@@ -301,27 +299,17 @@ tpm_extend_acpi_log(struct pcpes *pcpes,
{
u32 size;
- if (!has_working_tpm())
- return TCG_GENERAL_ERROR;
-
dprintf(DEBUG_tcg, "TCGBIOS: LASA = %p, next entry = %p\n",
tpm_state.log_area_start_address, tpm_state.log_area_next_entry);
- if (tpm_state.log_area_next_entry == NULL) {
-
- tpm_set_failure();
-
+ if (tpm_state.log_area_next_entry == NULL)
return TCG_PC_LOGOVERFLOW;
- }
size = offsetof(struct pcpes, event) + event_length;
if ((tpm_state.log_area_next_entry + size - tpm_state.log_area_start_address) >
tpm_state.log_area_minimum_length) {
dprintf(DEBUG_tcg, "TCGBIOS: LOG OVERFLOW: size = %d\n", size);
-
- tpm_set_failure();
-
return TCG_PC_LOGOVERFLOW;
}
@@ -548,7 +536,13 @@ hash_log_event(const void *hashdata, u32 hashdata_length,
return rc;
}
- return tpm_extend_acpi_log(pcpes, event, event_length, entry_count);
+ if (!has_working_tpm())
+ return TCG_GENERAL_ERROR;
+
+ rc = tpm_extend_acpi_log(pcpes, event, event_length, entry_count);
+ if (rc)
+ tpm_set_failure();
+ return rc;
}
static u32
--
2.5.0
More information about the SeaBIOS
mailing list