[PATCH] startup: don't fallback to shell from menu

Ahmad Fatoum a.fatoum at pengutronix.de
Mon Nov 25 07:39:15 PST 2024


The code to determine whether to drop to shell or to run the menu is a
bit hard to follow and may even be used to circumvent the menu in some
circumstances.

Fix this by wrapping the menu in an infinite loop and refuse dropping to
shell.

Suggested-by: Christian Melki <christian.melki at t2data.com>
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
 common/startup.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/common/startup.c b/common/startup.c
index d71d83c221dc..4c497d95bedb 100644
--- a/common/startup.c
+++ b/common/startup.c
@@ -318,16 +318,17 @@ static int run_init(void)
 	if (IS_ENABLED(CONFIG_NET) && !IS_ENABLED(CONFIG_CONSOLE_DISABLE_INPUT))
 		eth_open_all();
 
-	if (autoboot == AUTOBOOT_MENU)
+	if (autoboot != AUTOBOOT_MENU) {
+		if (autoboot == AUTOBOOT_ABORT && autoboot == global_autoboot_state)
+			watchdog_inhibit_all();
+
+		run_shell();
+	}
+
+	while (1)
 		run_command(MENUFILE);
 
-	if (autoboot == AUTOBOOT_ABORT && autoboot == global_autoboot_state)
-		watchdog_inhibit_all();
-
-	run_shell();
-	run_command(MENUFILE);
-
-	return 0;
+	unreachable();
 }
 
 typedef void (*ctor_fn_t)(void);
-- 
2.39.5




More information about the barebox mailing list