[PATCH 09/11] boot: bootm: release the imagemap on every failing exit

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


Three error paths in bootm_run_states() return directly instead of
reaching the err label, so the imagemap device and the LMB reservations
its translation table holds survive a failed bootm: the missing OS boot
function, an unsupported subcommand, and any error carried out of the
earlier states. The first of those also left interrupts disabled.

Route all three through err, which already releases the imagemap and
re-enables interrupts.

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

diff --git a/boot/bootm.c b/boot/bootm.c
index b6ae0163b27..92c8452a5d3 100644
--- a/boot/bootm.c
+++ b/boot/bootm.c
@@ -1265,18 +1265,17 @@ int bootm_run_states(struct bootm_info *bmi, int states)
 
 	/* From now on, we need the OS boot function */
 	if (ret)
-		return ret;
+		goto err;
 	boot_fn = bootm_os_get_boot_func(images->os.os);
 	need_boot_fn = states & (BOOTM_STATE_OS_CMDLINE |
 			BOOTM_STATE_OS_BD_T | BOOTM_STATE_OS_PREP |
 			BOOTM_STATE_OS_FAKE_GO | BOOTM_STATE_OS_GO);
 	if (boot_fn == NULL && need_boot_fn) {
-		if (iflag)
-			enable_interrupts();
 		printf("ERROR: booting os '%s' (%d) is not supported\n",
 		       genimg_get_os_name(images->os.os), images->os.os);
 		bootstage_error(BOOTSTAGE_ID_CHECK_BOOT_OS);
-		return 1;
+		ret = 1;
+		goto err;
 	}
 
 	/* Call various other states that are not generally used */
@@ -1318,7 +1317,7 @@ int bootm_run_states(struct bootm_info *bmi, int states)
 	/* Check for unsupported subcommand. */
 	if (ret) {
 		printf("subcommand failed (err=%d)\n", ret);
-		return ret;
+		goto err;
 	}
 
 	/* Now run the OS! We hope this doesn't return */
-- 
2.55.0



More information about the openwrt-devel mailing list