diff mbox series

efi_loader: Correctly account the SCRTM event creation

Message ID 20231107113134.81029-1-ilias.apalodimas@linaro.org
State Accepted
Commit 229f9e77fe46efb2516b7cfdc60db1d92721eac5
Headers show
Series efi_loader: Correctly account the SCRTM event creation | expand

Commit Message

Ilias Apalodimas Nov. 7, 2023, 11:31 a.m. UTC
The result of efi_append_scrtm_version() is overwritten before anyone
checks its result. Check it and exit the function on failures

Addresses-Coverity-ID: 467399 Code maintainability issues (UNUSED_VALUE)
Fixes: commit 97707f12fdab ("tpm: Support boot measurements")
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
---
 lib/efi_loader/efi_tcg2.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Heinrich Schuchardt Nov. 13, 2023, 2:12 p.m. UTC | #1
On 11/7/23 12:31, Ilias Apalodimas wrote:
> The result of efi_append_scrtm_version() is overwritten before anyone
> checks its result. Check it and exit the function on failures
>
> Addresses-Coverity-ID: 467399 Code maintainability issues (UNUSED_VALUE)
> Fixes: commit 97707f12fdab ("tpm: Support boot measurements")
> Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>

Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

> ---
>   lib/efi_loader/efi_tcg2.c | 5 ++++-
>   1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/lib/efi_loader/efi_tcg2.c b/lib/efi_loader/efi_tcg2.c
> index 2eaa12b83b16..463ea4c15416 100644
> --- a/lib/efi_loader/efi_tcg2.c
> +++ b/lib/efi_loader/efi_tcg2.c
> @@ -944,8 +944,11 @@ static efi_status_t efi_init_event_log(void)
>   	 * Add SCRTM version to the log if previous firmmware
>   	 * doesn't pass an eventlog.
>   	 */
> -	if (!elog.found)
> +	if (!elog.found) {
>   		ret = efi_append_scrtm_version(dev);
> +		if (ret != EFI_SUCCESS)
> +			goto free_pool;
> +	}
>
>   	ret = create_final_event();
>   	if (ret != EFI_SUCCESS)
diff mbox series

Patch

diff --git a/lib/efi_loader/efi_tcg2.c b/lib/efi_loader/efi_tcg2.c
index 2eaa12b83b16..463ea4c15416 100644
--- a/lib/efi_loader/efi_tcg2.c
+++ b/lib/efi_loader/efi_tcg2.c
@@ -944,8 +944,11 @@  static efi_status_t efi_init_event_log(void)
 	 * Add SCRTM version to the log if previous firmmware
 	 * doesn't pass an eventlog.
 	 */
-	if (!elog.found)
+	if (!elog.found) {
 		ret = efi_append_scrtm_version(dev);
+		if (ret != EFI_SUCCESS)
+			goto free_pool;
+	}
 
 	ret = create_final_event();
 	if (ret != EFI_SUCCESS)