]> xenbits.xensource.com Git - seabios.git/commitdiff
tpm: Move error recovery from tpm_extend_acpi_log() to only caller
authorKevin O'Connor <kevin@koconnor.net>
Sun, 22 Nov 2015 16:00:06 +0000 (11:00 -0500)
committerKevin O'Connor <kevin@koconnor.net>
Sun, 22 Nov 2015 17:14:28 +0000 (12:14 -0500)
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@koconnor.net>
src/tcgbios.c

index 7877840c725dd21695b21dab1823a23deb373ad9..88652fecd6dc5aaac9dbd5b3a98b45b0da8c5634 100644 (file)
@@ -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