All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matthias Schiffer <matthias.schiffer@ew.tq-group.com>
To: u-boot@lists.denx.de
Cc: Matthias Schiffer <matthias.schiffer@ew.tq-group.com>
Subject: [PATCH] fastboot: only look up real partition names when no alias exists
Date: Thu, 16 Dec 2021 11:26:38 +0100	[thread overview]
Message-ID: <20211216102638.111391-1-matthias.schiffer@ew.tq-group.com> (raw)

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>
---
 drivers/fastboot/fb_mmc.c | 29 ++++++++++++-----------------
 1 file changed, 12 insertions(+), 17 deletions(-)

diff --git a/drivers/fastboot/fb_mmc.c b/drivers/fastboot/fb_mmc.c
index 2738dc836e..fb7791d9da 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);
 }
 
 /**
-- 
2.25.1


             reply	other threads:[~2021-12-16 10:27 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-16 10:26 Matthias Schiffer [this message]
2021-12-17 23:20 ` [PATCH] fastboot: only look up real partition names when no alias exists Sean Anderson
2022-01-26  9:54   ` Matthias Schiffer
2022-01-27 16:22     ` Sean Anderson
2022-01-27 22:10       ` Tom Rini
2022-01-28 20:15 ` Tom Rini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211216102638.111391-1-matthias.schiffer@ew.tq-group.com \
    --to=matthias.schiffer@ew.tq-group.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.