To allow flashing an image with a partition table followed by an image for a specific partition, the fastboot implementation was changed to evaluate partitions on demand.
As there are partition-specific variables and the magic "all" variable, which lists all variables, all partitions are evaluated in getvar unconditionally, when only a variable for a specific partition is needed. When one partition doesn't exist and is not marked as optional, this leads to an error, even if something innocuous as the general max-download-size is requested. Change this, so only partitions that were explicitly asked for have their variables populated on demand, unless "all" variables were requested. Fixes: 6a191155be4e ("fastboot: evaluate fastboot partitions when used") Signed-off-by: Ahmad Fatoum <a.fat...@pengutronix.de> --- common/fastboot.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/common/fastboot.c b/common/fastboot.c index 231f49c1a6c9..529d9690db79 100644 --- a/common/fastboot.c +++ b/common/fastboot.c @@ -310,10 +310,15 @@ static void cb_getvar(struct fastboot *fb, const char *cmd) { LIST_HEAD(partition_list); struct file_list_entry *fentry; + const char *partition; bool all; pr_debug("getvar: \"%s\"\n", cmd); + partition = strchr(cmd, ':'); + if (partition) + partition++; + all = !strcmp(cmd, "all"); if (all) cmd = NULL; @@ -321,9 +326,15 @@ static void cb_getvar(struct fastboot *fb, const char *cmd) if (fastboot_tx_print_var(fb, &fb->variables, cmd)) goto out; + if (!all && !partition) + goto skip_partitions; + file_list_for_each_entry(fb->files, fentry) { int ret; + if (!all && strcmp(partition, fentry->name)) + continue; + ret = fastboot_add_partition_variables(fb, &partition_list, fentry); if (ret) { char *msg = xasprintf("%s: Failed to add '%s' partition variables: %pe", @@ -338,6 +349,7 @@ static void cb_getvar(struct fastboot *fb, const char *cmd) if (fastboot_tx_print_var(fb, &partition_list, cmd)) goto out; +skip_partitions: fastboot_tx_print(fb, FASTBOOT_MSG_OKAY, ""); out: fastboot_free_variables(&partition_list); -- 2.39.5