summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2025-06-20 08:01:16 -0600
committerTom Rini <trini@konsulko.com>2025-06-20 08:01:16 -0600
commit73fd2456231fe12db3bd5dbdab3f9f62bd8e643d (patch)
tree2e318f0fe1346bfe68d8df43baa5640bf1e345bb
parent4bbfd1c04277d83783266fae754b2227cbc5caae (diff)
parent8c61fc082e9ae045534dc2f18ed50493adf35e6d (diff)
Merge patch series "bootstd: Fix efi_mgr usage in bootmeths env var"
Sam Protsenko <semen.protsenko@linaro.org> says: Defining the 'bootmeths' environment variable with efi_mgr causes NULL pointer dereference when running 'bootflow scan' on the E850-96 board. This patch series fixes that, and cleans up the surrounding code a little while at it. Link: https://lore.kernel.org/r/20250112034213.13153-1-semen.protsenko@linaro.org
-rw-r--r--boot/bootmeth-uclass.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/boot/bootmeth-uclass.c b/boot/bootmeth-uclass.c
index 014b7588e8d..188f6ea1895 100644
--- a/boot/bootmeth-uclass.c
+++ b/boot/bootmeth-uclass.c
@@ -12,6 +12,7 @@
#include <bootmeth.h>
#include <bootstd.h>
#include <dm.h>
+#include <dm/device-internal.h>
#include <env_internal.h>
#include <fs.h>
#include <malloc.h>
@@ -135,10 +136,12 @@ int bootmeth_setup_iter_order(struct bootflow_iter *iter, bool include_global)
* We don't support skipping global bootmeths. Instead, the user
* should omit them from the ordering
*/
- if (!include_global)
- return log_msg_ret("glob", -EPERM);
+ if (!include_global) {
+ ret = log_msg_ret("glob", -EPERM);
+ goto err_order;
+ }
memcpy(order, std->bootmeth_order,
- count * sizeof(struct bootmeth *));
+ count * sizeof(struct udevice *));
if (IS_ENABLED(CONFIG_BOOTMETH_GLOBAL)) {
for (i = 0; i < count; i++) {
@@ -146,6 +149,12 @@ int bootmeth_setup_iter_order(struct bootflow_iter *iter, bool include_global)
struct bootmeth_uc_plat *ucp;
bool is_global;
+ ret = device_probe(dev);
+ if (ret) {
+ ret = log_msg_ret("probe", ret);
+ goto err_order;
+ }
+
ucp = dev_get_uclass_plat(dev);
is_global = ucp->flags &
BOOTMETHF_GLOBAL;
@@ -190,8 +199,10 @@ int bootmeth_setup_iter_order(struct bootflow_iter *iter, bool include_global)
}
count = upto;
}
- if (!count)
- return log_msg_ret("count2", -ENOENT);
+ if (!count) {
+ ret = log_msg_ret("count2", -ENOENT);
+ goto err_order;
+ }
if (IS_ENABLED(CONFIG_BOOTMETH_GLOBAL) && include_global &&
iter->first_glob_method != -1 && iter->first_glob_method != count) {
@@ -202,6 +213,10 @@ int bootmeth_setup_iter_order(struct bootflow_iter *iter, bool include_global)
iter->num_methods = count;
return 0;
+
+err_order:
+ free(order);
+ return ret;
}
int bootmeth_set_order(const char *order_str)