bootmenu: fix incorrect menu quitting logic

The last entry of bootmenu is always set for exiting the menu, and its
command is set to an empty string.

When user selects to quit the menu, bootmenu will try to run this empty
command. However run_command() with empty cmd string will return failure,
and the return value will be overridden to BOOTMENU_RET_FAIL, not the
expected BOOTMENU_RET_QUIT.

This patch adds a default success value to the cmd_ret variable, and makes
sure run_command() is called only when the menu command is not empty.

Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
This commit is contained in:
Weijie Gao
2026-06-10 14:49:43 -06:00
committed by Tom Rini
parent 953653936c
commit 1cc0442ede
+2 -2
View File
@@ -526,7 +526,7 @@ static void handle_uefi_bootnext(void)
*/
static enum bootmenu_ret bootmenu_show(int uefi, int delay)
{
int cmd_ret;
int cmd_ret = CMD_RET_SUCCESS;
int init = 0;
void *choice = NULL;
char *title = NULL;
@@ -628,7 +628,7 @@ cleanup:
printf(ANSI_CURSOR_POSITION, 1, 1);
}
if (title && command) {
if (title && command && *command) {
debug("Starting entry '%s'\n", title);
free(title);
if (efi_ret == EFI_SUCCESS)