mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] fixup! bootm: give bootm_load_ functions an end address
@ 2026-02-13  7:27 Ahmad Fatoum
  2026-02-13 14:07 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Ahmad Fatoum @ 2026-02-13  7:27 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

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




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-02-13 14:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-02-13  7:27 [PATCH] fixup! bootm: give bootm_load_ functions an end address Ahmad Fatoum
2026-02-13 14:07 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox