mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH master] startup: fix infinite loop falling into menu without /env/menu/mainmenu
@ 2025-01-07 11:08 Ahmad Fatoum
  2025-01-08 14:07 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages 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] 2+ messages in thread

* Re: [PATCH master] startup: fix infinite loop falling into menu without /env/menu/mainmenu
  2025-01-07 11:08 [PATCH master] startup: fix infinite loop falling into menu without /env/menu/mainmenu Ahmad Fatoum
@ 2025-01-08 14:07 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2025-01-08 14:07 UTC (permalink / raw)
  To: barebox, Ahmad Fatoum


On Tue, 07 Jan 2025 12:08:25 +0100, Ahmad Fatoum wrote:
> 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.
> 
> [...]

Applied, thanks!

[1/1] startup: fix infinite loop falling into menu without /env/menu/mainmenu
      https://git.pengutronix.de/cgit/barebox/commit/?id=427b037cf323 (link may not be stable)

Best regards,
-- 
Sascha Hauer <s.hauer@pengutronix.de>




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-01-08 14:07 UTC | newest]

Thread overview: 2+ messages (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
2025-01-08 14:07 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox