[PATCH] efi_loader: handle malloc() errors
Ilias Apalodimas
ilias.apalodimas at linaro.org
Tue Apr 1 13:31:58 CEST 2025
On Tue, 1 Apr 2025 at 14:15, Vincent Stehlé <vincent.stehle at arm.com> wrote:
>
> The new_packagelist() function of the HII Protocols implementation is
> calling malloc() without checking its return code; fix this.
>
> Signed-off-by: Vincent Stehlé <vincent.stehle at arm.com>
> Cc: Heinrich Schuchardt <xypron.glpk at gmx.de>
> Cc: Ilias Apalodimas <ilias.apalodimas at linaro.org>
> Cc: Tom Rini <trini at konsulko.com>
> ---
> lib/efi_loader/efi_hii.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/lib/efi_loader/efi_hii.c b/lib/efi_loader/efi_hii.c
> index 44235970a7c..330d7c5830b 100644
> --- a/lib/efi_loader/efi_hii.c
> +++ b/lib/efi_loader/efi_hii.c
> @@ -343,6 +343,9 @@ static struct efi_hii_packagelist *new_packagelist(void)
> struct efi_hii_packagelist *hii;
>
> hii = malloc(sizeof(*hii));
> + if (!hii)
> + return NULL;
> +
> list_add_tail(&hii->link, &efi_package_lists);
> hii->max_string_id = 0;
> INIT_LIST_HEAD(&hii->string_tables);
> --
> 2.47.2
>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas at linaro.org>
More information about the U-Boot
mailing list