mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Chali Anis <chalianis1@gmail.com>,
	Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH] efi: payload: do not check for heap addresses in efi_load_image
Date: Thu, 23 Oct 2025 08:59:06 +0200	[thread overview]
Message-ID: <20251023065907.2090100-1-a.fatoum@pengutronix.de> (raw)

We used to request memory from EFI only if read_file fails, but now that
read_file has been removed from efi_read_file, only EFI memory is used.

The check in efi_free_file for heap addresses thus serves no purpose any
longer and can be dropped.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 efi/payload/image.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/efi/payload/image.c b/efi/payload/image.c
index ae7678188d84..5d20221a135e 100644
--- a/efi/payload/image.c
+++ b/efi/payload/image.c
@@ -61,16 +61,6 @@ static void *efi_read_file(const char *file, size_t *size)
 	return buf;
 }
 
-static void efi_free_file(void *_mem, size_t size)
-{
-	efi_physical_addr_t mem = efi_virt_to_phys(_mem);
-
-	if (mem_malloc_start() <= mem && mem < mem_malloc_end())
-		free(_mem);
-	else
-		BS->free_pages(mem, DIV_ROUND_UP(size, EFI_PAGE_SIZE));
-}
-
 int efi_load_image(const char *file, struct efi_loaded_image **loaded_image,
 		   efi_handle_t *h)
 {
@@ -101,7 +91,7 @@ int efi_load_image(const char *file, struct efi_loaded_image **loaded_image,
 
 	*h = handle;
 out:
-	efi_free_file(exe, size);
+	BS->free_pages(efi_virt_to_phys(exe), DIV_ROUND_UP(size, EFI_PAGE_SIZE));
 	return -efi_errno(efiret);
 }
 
-- 
2.47.3




             reply	other threads:[~2025-10-23  6:59 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-23  6:59 Ahmad Fatoum [this message]
2025-10-23  7:44 ` Sascha Hauer

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=20251023065907.2090100-1-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=chalianis1@gmail.com \
    /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