From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH master] startup: fix infinite loop falling into menu without /env/menu/mainmenu
Date: Tue, 7 Jan 2025 12:08:25 +0100 [thread overview]
Message-ID: <20250107110825.3081026-1-a.fatoum@pengutronix.de> (raw)
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
next reply other threads:[~2025-01-07 11:10 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-07 11:08 Ahmad Fatoum [this message]
2025-01-08 14:07 ` Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250107110825.3081026-1-a.fatoum@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox