[PATCH] efi_loader: Fix UEFI variable error handling

Weizhao Ouyang o451686892 at gmail.com
Thu Nov 9 13:55:41 CET 2023


Correct some UEFI variable error handing code paths.

Signed-off-by: Weizhao Ouyang <o451686892 at gmail.com>
---
 lib/efi_loader/efi_var_file.c | 1 +
 lib/efi_loader/efi_variable.c | 8 ++++----
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/lib/efi_loader/efi_var_file.c b/lib/efi_loader/efi_var_file.c
index 62e071bd83..dbb9b1f3fc 100644
--- a/lib/efi_loader/efi_var_file.c
+++ b/lib/efi_loader/efi_var_file.c
@@ -236,6 +236,7 @@ efi_status_t efi_var_from_file(void)
 		log_err("Invalid EFI variables file\n");
 error:
 	free(buf);
+	return ret;
 #endif
 	return EFI_SUCCESS;
 }
diff --git a/lib/efi_loader/efi_variable.c b/lib/efi_loader/efi_variable.c
index be95ed44e6..13966297c6 100644
--- a/lib/efi_loader/efi_variable.c
+++ b/lib/efi_loader/efi_variable.c
@@ -350,17 +350,17 @@ efi_status_t efi_set_variable_int(const u16 *variable_name,
 
 	if (var_type == EFI_AUTH_VAR_PK)
 		ret = efi_init_secure_state();
-	else
-		ret = EFI_SUCCESS;
+	if (ret != EFI_SUCCESS)
+		return ret;
 
 	/*
 	 * Write non-volatile EFI variables to file
 	 * TODO: check if a value change has occured to avoid superfluous writes
 	 */
 	if (attributes & EFI_VARIABLE_NON_VOLATILE)
-		efi_var_to_file();
+		ret = efi_var_to_file();
 
-	return EFI_SUCCESS;
+	return ret;
 }
 
 efi_status_t efi_query_variable_info_int(u32 attributes,
-- 
2.39.2



More information about the U-Boot mailing list