summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorMatthias Schiffer <matthias.schiffer@ew.tq-group.com>2021-12-16 11:26:38 +0100
committerTom Rini <trini@konsulko.com>2022-01-28 11:30:39 -0500
commit7e90f771730001f9ba749985f81103930e892eaf (patch)
tree9e15e28efddfbbb0c2cad90aefd6affca0074a36 /drivers
parent86b6a38863bebb70a65a53f93a1ffafc4a472169 (diff)
downloadu-boot-7e90f771730001f9ba749985f81103930e892eaf.tar.gz
u-boot-7e90f771730001f9ba749985f81103930e892eaf.tar.bz2
u-boot-7e90f771730001f9ba749985f81103930e892eaf.zip
fastboot: only look up real partition names when no alias exists
Having U-Boot look up the passed partition name even though an alias exists is unexpected, leading to warning messages (when the alias name doesn't exist as a real partition name) or the use of the wrong partition. Change part_get_info_by_name_or_alias() to consider real partitions names only if no alias of the same name exists, allowing to use aliases to override the configuration for existing partition names. Also change one use of strcpy() to strlcpy(). Signed-off-by: Matthias Schiffer <matthias.schiffer@ew.tq-group.com> Reviewed-by: Sean Anderson <sean.anderson@seco.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/fastboot/fb_mmc.c29
1 files changed, 12 insertions, 17 deletions
diff --git a/drivers/fastboot/fb_mmc.c b/drivers/fastboot/fb_mmc.c
index 2710879812..c62e414306 100644
--- a/drivers/fastboot/fb_mmc.c
+++ b/drivers/fastboot/fb_mmc.c
@@ -104,23 +104,18 @@ static int part_get_info_by_name_or_alias(struct blk_desc **dev_desc,
const char *name,
struct disk_partition *info)
{
- int ret;
-
- ret = do_get_part_info(dev_desc, name, info);
- if (ret < 0) {
- /* strlen("fastboot_partition_alias_") + PART_NAME_LEN + 1 */
- char env_alias_name[25 + PART_NAME_LEN + 1];
- char *aliased_part_name;
-
- /* check for alias */
- strcpy(env_alias_name, "fastboot_partition_alias_");
- strlcat(env_alias_name, name, sizeof(env_alias_name));
- aliased_part_name = env_get(env_alias_name);
- if (aliased_part_name != NULL)
- ret = do_get_part_info(dev_desc, aliased_part_name,
- info);
- }
- return ret;
+ /* strlen("fastboot_partition_alias_") + PART_NAME_LEN + 1 */
+ char env_alias_name[25 + PART_NAME_LEN + 1];
+ char *aliased_part_name;
+
+ /* check for alias */
+ strlcpy(env_alias_name, "fastboot_partition_alias_", sizeof(env_alias_name));
+ strlcat(env_alias_name, name, sizeof(env_alias_name));
+ aliased_part_name = env_get(env_alias_name);
+ if (aliased_part_name)
+ name = aliased_part_name;
+
+ return do_get_part_info(dev_desc, name, info);
}
/**