U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Heinrich Schuchardt <xypron.glpk@gmx.de>
To: Simon Glass <sjg@chromium.org>
Cc: Matthew Garrett <mgarrett@aurora.tech>,
	Ilias Apalodimas <ilias.apalodimas@linaro.org>,
	Janis Danisevskis <jdanisevskis@aurora.tech>,
	Tom Rini <trini@konsulko.com>,
	U-Boot Mailing List <u-boot@lists.denx.de>
Subject: Re: [PATCH 8/8] efi: Avoid a memory leak in efi_bind_block() on error path
Date: Tue, 10 Dec 2024 09:10:06 +0100	[thread overview]
Message-ID: <c95a1f38-43e7-4198-8763-4856defbc9ba@gmx.de> (raw)
In-Reply-To: <20241209162801.288363-9-sjg@chromium.org>

On 09.12.24 17:28, Simon Glass wrote:
> Free the memory used if an error occurs.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> Suggested-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
> ---
>
>   lib/efi/efi_app_init.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/lib/efi/efi_app_init.c b/lib/efi/efi_app_init.c
> index cc91e1d74b8..fec3f348cfb 100644
> --- a/lib/efi/efi_app_init.c
> +++ b/lib/efi/efi_app_init.c
> @@ -60,8 +60,10 @@ int efi_bind_block(efi_handle_t handle, struct efi_block_io *blkio,
>   	plat->handle = handle;
>   	plat->blkio = blkio;
>   	plat->device_path = malloc(device_path_len);
> -	if (!plat->device_path)
> +	if (!plat->device_path) {
> +		free(plat);

As of origin master origin/next (9dd0a9ecaa539ad) plat is a local
variable and not a pointer. You cannot free it.

If there is some prerequisite patch that is making plat a pointer, you
should add this correction to that patch.

Best regards

Heinrich

>   		return log_msg_ret("path", -ENOMEM);
> +	}
>   	memcpy(plat->device_path, device_path, device_path_len);
>   	ret = device_bind(dm_root(), DM_DRIVER_GET(efi_media), "efi_media",
>   			  plat, ofnode_null(), &dev);


  reply	other threads:[~2024-12-10  8:10 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-09 16:27 [PATCH 0/8] efi: Add docs and tests and a few tweaks Simon Glass
2024-12-09 16:27 ` [PATCH 1/8] fdtdec: Correct devicetree symbol for EFI app Simon Glass
2024-12-09 16:27 ` [PATCH 2/8] part_find: Enable for sandbox and correct radix and calls Simon Glass
2024-12-09 16:27 ` [PATCH 3/8] doc: test: Add docs and test for part_find Simon Glass
2024-12-10  8:15   ` Heinrich Schuchardt
2024-12-10 16:16     ` Simon Glass
2024-12-10 17:08       ` Tom Rini
2024-12-16  0:29         ` Simon Glass
2024-12-16  8:05           ` Heinrich Schuchardt
2024-12-09 16:27 ` [PATCH 4/8] efi: Drop config.h Simon Glass
2024-12-09 16:27 ` [PATCH 5/8] cmd: Refactor part_find() into separate functions Simon Glass
2024-12-09 16:27 ` [PATCH 6/8] addr_find: Use a simple lmb allocation Simon Glass
2024-12-09 16:28 ` [PATCH 7/8] doc: test: Add docs and test for addr_find Simon Glass
2024-12-09 16:28 ` [PATCH 8/8] efi: Avoid a memory leak in efi_bind_block() on error path Simon Glass
2024-12-10  8:10   ` Heinrich Schuchardt [this message]
2024-12-16 15:15     ` Simon Glass

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=c95a1f38-43e7-4198-8763-4856defbc9ba@gmx.de \
    --to=xypron.glpk@gmx.de \
    --cc=ilias.apalodimas@linaro.org \
    --cc=jdanisevskis@aurora.tech \
    --cc=mgarrett@aurora.tech \
    --cc=sjg@chromium.org \
    --cc=trini@konsulko.com \
    --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