]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
menu: menu_get_choice() return -ENOENT if menu item is empty
authorMasahisa Kojima <masahisa.kojima@linaro.org>
Thu, 28 Apr 2022 08:09:37 +0000 (17:09 +0900)
committerHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Tue, 3 May 2022 19:39:22 +0000 (21:39 +0200)
menu_get_choice() needs to handle the case that menu item
is empty. In this case, menu_get_choice() returns -ENOENT.

Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org>
Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
common/menu.c

index b577d80b4ff6467ce34fa90f8b03ced9f3eb7048..f5fc6930a2cb5fd428fa61164bffa238b11a49b7 100644 (file)
@@ -271,6 +271,9 @@ int menu_get_choice(struct menu *m, void **choice)
        if (!m || !choice)
                return -EINVAL;
 
+       if (!m->item_cnt)
+               return -ENOENT;
+
        if (!m->prompt)
                return menu_default_choice(m, choice);