This function calls a function which can fail. Print a message in this
case and abort the boot, rather than silently continuing to boot, which
will certainly fail.

Signed-off-by: Simon Glass <s...@chromium.org>
---

Changes in v3: None
Changes in v2:
- Change return type of efi_init_obj_list() to efi_status_t
- Convert #ifdef CONFIG_GENERATE_SMBIOS_TABLE to if()

 cmd/bootefi.c | 32 ++++++++++++++++++++++++--------
 1 file changed, 24 insertions(+), 8 deletions(-)

diff --git a/cmd/bootefi.c b/cmd/bootefi.c
index 064c069757..259f80a0d8 100644
--- a/cmd/bootefi.c
+++ b/cmd/bootefi.c
@@ -27,11 +27,17 @@ static uint8_t efi_obj_list_initialised;
 static struct efi_device_path *bootefi_image_path;
 static struct efi_device_path *bootefi_device_path;
 
-/* Initialize and populate EFI object list */
-static void efi_init_obj_list(void)
+/**
+ * efi_init_obj_list() - Initialize and populate EFI object list
+ *
+ * @return 0 if OK, -ve on error (in which case it prints a message)
+ */
+static efi_status_t efi_init_obj_list(void)
 {
+       efi_status_t ret;
+
        if (efi_obj_list_initialised)
-               return;
+               return 0;
        efi_obj_list_initialised = 1;
 
        /* Initialize EFI driver uclass */
@@ -47,14 +53,21 @@ static void efi_init_obj_list(void)
 #ifdef CONFIG_NET
        efi_net_register();
 #endif
-#ifdef CONFIG_GENERATE_SMBIOS_TABLE
-       efi_smbios_register();
-#endif
+       if (IS_ENABLED(GENERATE_SMBIOS_TABLE)) {
+               ret = efi_smbios_register();
+               if (ret)
+                       goto error;
+       }
        efi_watchdog_register();
 
        /* Initialize EFI runtime services */
        efi_reset_system_init();
        efi_get_time_init();
+
+       return EFI_SUCCESS;
+error:
+       printf("Error: Cannot set up EFI object list (err=%lx)\n", ret);
+       return ret;
 }
 
 /*
@@ -186,7 +199,9 @@ static efi_status_t do_bootefi_exec(void *efi, void *fdt,
        }
 
        /* Initialize and populate EFI object list */
-       efi_init_obj_list();
+       ret = efi_init_obj_list();
+       if (ret)
+               return ret;
 
        efi_setup_loaded_image(&loaded_image_info, &loaded_image_info_obj,
                               device_path, image_path);
@@ -350,7 +365,8 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, 
char * const argv[])
                 */
                efi_save_gd();
                /* Initialize and populate EFI object list */
-               efi_init_obj_list();
+               if (efi_init_obj_list())
+                       return CMD_RET_FAILURE;
                /* Transfer environment variable efi_selftest as load options */
                set_load_options(&loaded_image_info, "efi_selftest");
                /* Execute the test */
-- 
2.16.1.291.g4437f3f132-goog

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot

Reply via email to