summaryrefslogtreecommitdiff
path: root/boot/bootflow_menu.c
diff options
context:
space:
mode:
authorQuentin Schulz <[email protected]>2024-06-12 16:58:49 +0200
committerTom Rini <[email protected]>2024-06-20 11:41:43 -0600
commit05b9665f095f2f70bf8de7ea6d1f5efc2ce7fb35 (patch)
tree94ae2f1edbdfed61d764ebb4c556158006d95a13 /boot/bootflow_menu.c
parent817316663626548f8e5b4d3019e4da957dcf2b59 (diff)
boot: bootflow_menu: fix crash for EFI BOOTMGR global bootmeth
The global bootmeths don't set the dev in bootflow struct which means the dev_get_parent(bflow->dev) triggers a NULL-pointer dereference and crash U-Boot. So before trying to handle a bootflow, check that the associated bootmeth isn't global, otherwise skip it. Suggested-by: Simon Glass <[email protected]> Signed-off-by: Quentin Schulz <[email protected]> Reviewed-by: Simon Glass <[email protected]>
Diffstat (limited to 'boot/bootflow_menu.c')
-rw-r--r--boot/bootflow_menu.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/boot/bootflow_menu.c b/boot/bootflow_menu.c
index 143ef841332..9d0dc352f97 100644
--- a/boot/bootflow_menu.c
+++ b/boot/bootflow_menu.c
@@ -9,6 +9,7 @@
#define LOG_CATEGORY UCLASS_BOOTSTD
#include <bootflow.h>
+#include <bootmeth.h>
#include <bootstd.h>
#include <cli.h>
#include <dm.h>
@@ -76,6 +77,7 @@ int bootflow_menu_new(struct expo **expp)
last_bootdev = NULL;
for (ret = bootflow_first_glob(&bflow), i = 0; !ret && i < 36;
ret = bootflow_next_glob(&bflow), i++) {
+ struct bootmeth_uc_plat *ucp;
char str[2], *label, *key;
uint preview_id;
bool add_gap;
@@ -83,6 +85,11 @@ int bootflow_menu_new(struct expo **expp)
if (bflow->state != BOOTFLOWST_READY)
continue;
+ /* No media to show for BOOTMETHF_GLOBAL bootmeths */
+ ucp = dev_get_uclass_plat(bflow->method);
+ if (ucp->flags & BOOTMETHF_GLOBAL)
+ continue;
+
*str = i < 10 ? '0' + i : 'A' + i - 10;
str[1] = '\0';
key = strdup(str);