]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
boot: bootflow_menu: fix crash for EFI BOOTMGR global bootmeth
authorQuentin Schulz <quentin.schulz@cherry.de>
Wed, 12 Jun 2024 14:58:49 +0000 (16:58 +0200)
committerTom Rini <trini@konsulko.com>
Thu, 20 Jun 2024 17:41:43 +0000 (11:41 -0600)
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 <sjg@chromium.org>
Signed-off-by: Quentin Schulz <quentin.schulz@cherry.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
boot/bootflow_menu.c
include/bootflow.h

index 143ef8413326e079bebe0649433ed0178bc08dad..9d0dc352f97e5feb543fda93ac20b04c57b1e55f 100644 (file)
@@ -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);
index 080ee850122556ed15735cbccdbb27f42b3ef680..6affc5e1a4f3a9e02bf373baf140821aabfcf7a2 100644 (file)
@@ -63,7 +63,8 @@ enum bootflow_flags_t {
  *
  * @bm_node: Points to siblings in the same bootdev
  * @glob_node: Points to siblings in the global list (all bootdev)
- * @dev: Bootdev device which produced this bootflow
+ * @dev: Bootdev device which produced this bootflow, NULL for flows created by
+ *      BOOTMETHF_GLOBAL bootmeths
  * @blk: Block device which contains this bootflow, NULL if this is a network
  *     device or sandbox 'host' device
  * @part: Partition number (0 for whole device)