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: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH] fixup! bootm: give bootm_load_ functions an end address
Date: Fri, 13 Feb 2026 08:27:18 +0100	[thread overview]
Message-ID: <20260213072718.1893389-1-a.fatoum@pengutronix.de> (raw)

booti: fix use of uninitialized end variable

If a fixed OS load address is set, get_kernel_address() will not set end
leading to an uninitialized end value to be passed to bootm_load_os().

Fix this by determining the gap the fixed OS load address is located in
and passing that along instead.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 common/booti.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/common/booti.c b/common/booti.c
index 4f6ccf95f85c..ba7e6081e6ce 100644
--- a/common/booti.c
+++ b/common/booti.c
@@ -14,6 +14,7 @@ static unsigned long get_kernel_address(unsigned long os_address,
 					resource_size_t *end)
 {
 	resource_size_t start;
+	struct resource *sdram, gap;
 	int ret;
 
 	if (!UIMAGE_IS_ADDRESS_VALID(os_address)) {
@@ -24,6 +25,12 @@ static unsigned long get_kernel_address(unsigned long os_address,
 		return ALIGN(start, SZ_2M) + text_offset;
 	}
 
+	sdram = memory_bank_lookup_region(os_address, &gap);
+	if (sdram != &gap)
+		return UIMAGE_INVALID_ADDRESS;
+
+	*end = gap.end;
+
 	if (os_address >= text_offset && IS_ALIGNED(os_address - text_offset, SZ_2M))
 		return os_address;
 
@@ -52,7 +59,8 @@ void *booti_load_image(struct image_data *data, phys_addr_t *oftree)
 
 	kernel = get_kernel_address(data->os_address, text_offset, &end);
 
-	pr_debug("Kernel to be loaded to %lx+%lx\n", kernel, image_size);
+	pr_debug("Kernel (size: %lx) to be loaded into %lx+%llx\n",
+		 image_size, kernel, end);
 
 	if (kernel == UIMAGE_INVALID_ADDRESS)
 		return ERR_PTR(-ENOENT);
-- 
2.47.3




             reply	other threads:[~2026-02-13  7:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-13  7:27 Ahmad Fatoum [this message]
2026-02-13 14:07 ` 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=20260213072718.1893389-1-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /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