]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
bootmenu: fix incorrect menu quitting logic
authorWeijie Gao <weijie.gao@mediatek.com>
Tue, 26 May 2026 08:37:29 +0000 (16:37 +0800)
committerTom Rini <trini@konsulko.com>
Wed, 10 Jun 2026 20:49:43 +0000 (14:49 -0600)
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>
cmd/bootmenu.c

index 528afd221d050479ffee1ca8cc3ab9d16a7db0a4..b55f5579409149509707e213ccace11d4715aad9 100644 (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)