public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: AKASHI Takahiro <takahiro.akashi@linaro.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 1/1] efi_loader: HII protocols: fix new_package_list()
Date: Fri, 1 Mar 2019 09:54:44 +0900	[thread overview]
Message-ID: <20190301005443.GW20286@linaro.org> (raw)
In-Reply-To: <20190228222034.18644-1-xypron.glpk@gmx.de>

On Thu, Feb 28, 2019 at 11:20:34PM +0100, Heinrich Schuchardt wrote:
> In new_package_list() we call new_packagelist() to create a new package
> list. Next we try to add the packages which fails for form packages. Due
> to this error we call free_packagelist(). Now in free_packagelist()
> list_del() is called for an uninitialized field hii->link. This leads to
> changing random memory addresses.
> 
> To solve the problem move the initialization of hii->link to
> new_packagelist().
> 
> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> ---
> @Takahiro:
> Please, review the patch.

Good catch, thank you.

Reviewed-by: AKASHI Takahiro <takahiro.akashi@linaro.org>

> ---
>  lib/efi_loader/efi_hii.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/efi_loader/efi_hii.c b/lib/efi_loader/efi_hii.c
> index d63d2d84184..0ed4b196333 100644
> --- a/lib/efi_loader/efi_hii.c
> +++ b/lib/efi_loader/efi_hii.c
> @@ -343,6 +343,7 @@ static struct efi_hii_packagelist *new_packagelist(void)
>  	struct efi_hii_packagelist *hii;
>  
>  	hii = malloc(sizeof(*hii));
> +	list_add_tail(&hii->link, &efi_package_lists);
>  	hii->max_string_id = 0;
>  	INIT_LIST_HEAD(&hii->string_tables);
>  	INIT_LIST_HEAD(&hii->guid_list);
> @@ -465,7 +466,6 @@ new_package_list(const struct efi_hii_database_protocol *this,
>  	}
>  
>  	hii->driver_handle = driver_handle;
> -	list_add_tail(&hii->link, &efi_package_lists);
>  	*handle = hii;
>  
>  	return EFI_EXIT(EFI_SUCCESS);
> -- 
> 2.20.1
> 

  reply	other threads:[~2019-03-01  0:54 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-28 22:20 [U-Boot] [PATCH 1/1] efi_loader: HII protocols: fix new_package_list() Heinrich Schuchardt
2019-03-01  0:54 ` AKASHI Takahiro [this message]
2019-03-02 21:47   ` Heinrich Schuchardt
2019-03-02 16:32 ` Alexander Graf
2019-03-02 22:08   ` Heinrich Schuchardt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190301005443.GW20286@linaro.org \
    --to=takahiro.akashi@linaro.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox