[PATCH v2 4/8] efi_loader: load device-tree specified in boot option

Ilias Apalodimas ilias.apalodimas at linaro.org
Tue May 28 17:40:24 CEST 2024


[...]

> +
> +       *fdt = malloc(filesize);

Use calloc instead

> +       if (!*fdt) {
> +               log_err("Out of memory\n");
> +               ret = EFI_OUT_OF_RESOURCES;
> +               goto out;
> +       }
> +       ret = EFI_CALL(f->read(f, &filesize, *fdt));
> +       if (ret != EFI_SUCCESS) {
> +               log_err("Can't read fdt\n");
> +               free(*fdt);
> +               *fdt = NULL;
> +       }
> +
> +out:
> +       efi_free_pool(dp);
> +       if (f)
> +               EFI_CALL(f->close(f));
> +
> +       return ret;
> +}
> +
>  /**
>   * efi_bootmgr_run() - execute EFI boot manager
>   * @fdt:       Flat device tree
> @@ -1200,6 +1253,7 @@ efi_status_t efi_bootmgr_run(void *fdt)
>         efi_handle_t handle;
>         void *load_options;
>         efi_status_t ret;
> +       void *fdt_lo;
>
>         /* Initialize EFI drivers */
>         ret = efi_init_obj_list();
> @@ -1215,7 +1269,23 @@ efi_status_t efi_bootmgr_run(void *fdt)
>                 return ret;
>         }
>
> +       if (!IS_ENABLED(CONFIG_GENERATE_ACPI_TABLE)) {
> +               ret = load_fdt_from_load_option(&fdt_lo);
> +               if (ret != EFI_SUCCESS)
> +                       return ret;
> +               if (fdt_lo)
> +                       fdt = fdt_lo;
> +       }
> +
> +       /*
> +        * Needed in ACPI case to create reservations based on
> +        * control device-tree.
> +        */
>         ret = efi_install_fdt(fdt);
> +
> +       if (!IS_ENABLED(CONFIG_GENERATE_ACPI_TABLE))
> +               free(fdt_lo);
> +
>         if (ret != EFI_SUCCESS) {
>                 if (EFI_CALL(efi_unload_image(handle)) == EFI_SUCCESS)
>                         free(load_options);
> --
> 2.43.0
>

Reviewed-by: Ilias Apalodimas <ilias.apalodimas at linaro.org>


More information about the U-Boot mailing list