libstub,tpm: do not ignore failure case when reading final event log

Current code fails to check for an error case when reading events
from final event log to calculate offsets.  Check the error case,
and break early because all subsequent calls will also fail.

Signed-off-by: Gregory Price <gourry@gourry.net>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
This commit is contained in:
Gregory Price 2024-09-13 19:19:54 -04:00 committed by Ard Biesheuvel
parent a066397e8e
commit 63971b0f51

View File

@ -124,6 +124,9 @@ static void efi_retrieve_tcg2_eventlog(int version, efi_physical_addr_t log_loca
event_size = __calc_tpm2_event_size(header,
(void *)(long)log_location,
false);
/* If calc fails this is a malformed log */
if (!event_size)
break;
final_events_size += event_size;
i--;
}