* [PATCH master] startup: fix infinite loop falling into menu without /env/menu/mainmenu
@ 2025-01-07 11:08 Ahmad Fatoum
0 siblings, 0 replies; only message in thread
From: Ahmad Fatoum @ 2025-01-07 11:08 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
If MENUFILE (/env/menu/mainmenu) doesn't exist, an infinite loop will
keep executing this non-existent file.
If this happens, let's exit the infinite loop and hang barebox instead.
Previously we dropped to a shell in this situation, but this was changed
as menu-only boots should not be circumventable and drop to a shell due
to errors.
Fixes: 96852a962d0c ("startup: don't fallback to shell from menu")
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
common/startup.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/common/startup.c b/common/startup.c
index 723d4f1ecc3b..3debb6668be7 100644
--- a/common/startup.c
+++ b/common/startup.c
@@ -344,10 +344,15 @@ static int run_init(void)
run_shell();
}
- while (1)
+ do {
+ /*
+ * Let's run the command once at least, so an error
+ * message is printed if the file doesn't exist
+ */
run_command(MENUFILE);
+ } while (stat(MENUFILE, &s) == 0);
- unreachable();
+ hang();
}
typedef void (*ctor_fn_t)(void);
--
2.39.5
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2025-01-07 11:10 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-01-07 11:08 [PATCH master] startup: fix infinite loop falling into menu without /env/menu/mainmenu Ahmad Fatoum
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox