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@xxxxxxxxxx> Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx> --- 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