diff --git a/board/theobroma-systems/common/common.c b/board/theobroma-systems/common/common.c index eb21d4c455..864bcdd46f 100644 --- a/board/theobroma-systems/common/common.c +++ b/board/theobroma-systems/common/common.c @@ -21,7 +21,9 @@ int setup_boottargets(void) { const char *boot_device = ofnode_read_chosen_string("u-boot,spl-boot-device"); - char *env_default, *env; + char env_default[sizeof(BOOT_TARGETS)]; + char *env; + int ret; if (!boot_device) { debug("%s: /chosen/u-boot,spl-boot-device not set\n", @@ -30,7 +32,9 @@ int setup_boottargets(void) } debug("%s: booted from %s\n", __func__, boot_device); - env_default = env_get_default("boot_targets"); + ret = env_get_default_into("boot_targets", env_default, sizeof(env_default)); + if (ret < 0) + env_default[0] = '\0'; env = env_get("boot_targets"); if (!env) { debug("%s: boot_targets does not exist\n", __func__);