From: Simon Glass <sjg@chromium.org>
To: U-Boot Mailing List <u-boot@lists.denx.de>
Cc: Matthew Garrett <mgarrett@aurora.tech>,
Simon Glass <sjg@chromium.org>,
Ilias Apalodimas <ilias.apalodimas@linaro.org>,
Heinrich Schuchardt <xypron.glpk@gmx.de>,
Janis Danisevskis <jdanisevskis@aurora.tech>,
Tom Rini <trini@konsulko.com>
Subject: [PATCH 8/8] efi: Avoid a memory leak in efi_bind_block() on error path
Date: Mon, 9 Dec 2024 09:28:01 -0700 [thread overview]
Message-ID: <20241209162801.288363-9-sjg@chromium.org> (raw)
In-Reply-To: <20241209162801.288363-1-sjg@chromium.org>
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);
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);
--
2.34.1
next prev parent reply other threads:[~2024-12-09 16:30 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 ` Simon Glass [this message]
2024-12-10 8:10 ` [PATCH 8/8] efi: Avoid a memory leak in efi_bind_block() on error path Heinrich Schuchardt
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=20241209162801.288363-9-sjg@chromium.org \
--to=sjg@chromium.org \
--cc=ilias.apalodimas@linaro.org \
--cc=jdanisevskis@aurora.tech \
--cc=mgarrett@aurora.tech \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
--cc=xypron.glpk@gmx.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