aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Golle <daniel@makrotopia.org>2023-06-04 18:21:29 +0100
committerDaniel Golle <daniel@makrotopia.org>2023-06-09 19:23:03 +0100
commitdc778190bc9ce68dc57ec54e730b797c63666d56 (patch)
tree3b1a550dc143c591b392eac18c5830a9003ea11e
parentd05d886d22ed1f395d7d4ee47b2e2075b58fa9b9 (diff)
downloadupstream-dc778190bc9ce68dc57ec54e730b797c63666d56.tar.gz
upstream-dc778190bc9ce68dc57ec54e730b797c63666d56.tar.bz2
upstream-dc778190bc9ce68dc57ec54e730b797c63666d56.zip
generic: use only first element in bootconf for uImage.FIT
Now that it is possible to load several device tree overlays by appending their config names to bootconf the uImage.FIT partition parser need to discard everything after the first '#' character in bootconf when looking up the config node to be used. Signed-off-by: Daniel Golle <daniel@makrotopia.org> (cherry picked from commit 07bca1adaa0de71d0aefcf83bff2e1d90616cd3d)
-rw-r--r--target/linux/generic/files/block/partitions/fit.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/target/linux/generic/files/block/partitions/fit.c b/target/linux/generic/files/block/partitions/fit.c
index 13c03743f3..91b25e0581 100644
--- a/target/linux/generic/files/block/partitions/fit.c
+++ b/target/linux/generic/files/block/partitions/fit.c
@@ -84,13 +84,13 @@ int parse_fit_partitions(struct parsed_partitions *state, u64 fit_start_sector,
const u32 *image_offset_be, *image_len_be, *image_pos_be;
int ret = 1, node, images, config;
const char *image_name, *image_type, *image_description, *config_default,
- *config_description, *config_loadables;
+ *config_description, *config_loadables, *bootconf_c;
int image_name_len, image_type_len, image_description_len, config_default_len,
- config_description_len, config_loadables_len;
+ config_description_len, config_loadables_len, bootconf_len;
sector_t start_sect, nr_sects;
size_t label_min;
struct device_node *np = NULL;
- const char *bootconf;
+ char *bootconf = NULL, *bootconf_term;
const char *loadable;
const char *select_rootfs = NULL;
bool found;
@@ -143,10 +143,17 @@ int parse_fit_partitions(struct parsed_partitions *state, u64 fit_start_sector,
return -ENOMEM;
np = of_find_node_by_path("/chosen");
- if (np)
- bootconf = of_get_property(np, "u-boot,bootconf", NULL);
- else
- bootconf = NULL;
+ if (np) {
+ bootconf_c = of_get_property(np, "u-boot,bootconf", &bootconf_len);
+ if (bootconf_c && bootconf_len)
+ bootconf = kmemdup_nul(bootconf_c, bootconf_len, GFP_KERNEL);
+ }
+
+ if (bootconf) {
+ bootconf_term = strchr(bootconf, '#');
+ if (bootconf_term)
+ *bootconf_term = '\0';
+ }
config = fdt_path_offset(fit, FIT_CONFS_PATH);
if (config < 0) {
@@ -285,6 +292,7 @@ int parse_fit_partitions(struct parsed_partitions *state, u64 fit_start_sector,
strlcat(state->pp_buf, tmp, PAGE_SIZE);
}
ret_out:
+ kfree(bootconf);
kfree(fit);
return ret;
}