[PATCH 07/11] boot: fit: unmap the load address after a storage read

Daniel Golle daniel at makrotopia.org
Mon Sep 28 17:05:38 PDT 2026


fit_image_load_storage() maps the load address to get a destination for
imagemap_map_to() and never unmaps it. The mapping is a no-op on most
architectures but not on sandbox, which is where the unit tests run.

Pair the map_sysmem() with an unmap_sysmem() once the read is done.

Fixes: 46d32e38ee4e ("boot: fit: support on-demand loading in fit_image_load()")
Signed-off-by: Daniel Golle <daniel at makrotopia.org>
---
 boot/image-fit.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/boot/image-fit.c b/boot/image-fit.c
index 60e47db5fb0..5d86342852c 100644
--- a/boot/image-fit.c
+++ b/boot/image-fit.c
@@ -2190,6 +2190,7 @@ static int fit_image_load_storage(struct bootm_headers *images, const void *fit,
 	ulong img_load;
 	u8 img_comp = IH_COMP_NONE;
 	void *mapped;
+	void *dst;
 
 	if (CONFIG_IS_ENABLED(FIT_VERITY)) {
 		u8 img_type;
@@ -2222,10 +2223,11 @@ static int fit_image_load_storage(struct bootm_headers *images, const void *fit,
 
 	if (img_comp == IH_COMP_NONE && load_op != FIT_LOAD_IGNORED &&
 	    !fit_image_get_load(fit, noffset, &img_load)) {
-		void *dst = map_sysmem(img_load, data_sz);
+		dst = map_sysmem(img_load, data_sz);
 
 		mapped = imagemap_map_to(images->imagemap, data_off, data_sz,
 					 dst);
+		unmap_sysmem(dst);
 	} else {
 		mapped = imagemap_map(images->imagemap, data_off, data_sz);
 	}
-- 
2.55.0



More information about the openwrt-devel mailing list