From patchwork Thu Dec 16 10:26:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthias Schiffer X-Patchwork-Id: 1569034 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=tq-group.com header.i=@tq-group.com header.a=rsa-sha256 header.s=key1 header.b=FSpXLaZ9; dkim=pass (2048-bit key) header.d=tq-group.com header.i=@tq-group.com header.a=rsa-sha256 header.s=key1 header.b=L4Fut5/x; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JF7bX5jn6z9s3q for ; Thu, 16 Dec 2021 21:27:34 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id DD75282FB5; Thu, 16 Dec 2021 11:27:23 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=ew.tq-group.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=tq-group.com header.i=@tq-group.com header.b="FSpXLaZ9"; dkim=pass (2048-bit key) header.d=tq-group.com header.i=@tq-group.com header.b="L4Fut5/x"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3F72182FE2; Thu, 16 Dec 2021 11:27:22 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mx1.tq-group.com (mx1.tq-group.com [93.104.207.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id E082E80379 for ; Thu, 16 Dec 2021 11:27:18 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=ew.tq-group.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=matthias.schiffer@ew.tq-group.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tq-group.com; i=@tq-group.com; q=dns/txt; s=key1; t=1639650438; x=1671186438; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=f0fdQRX8De3W+inCWTedL31kMAynX9IsLrhxj70v9GQ=; b=FSpXLaZ9j9ze8ZxJdn81TBJoRUFS35fWmhw0R14MjsoZfIyXDkga66N4 prQRrIJTnF+TQ6CJLgPRJ6op0rTInKVsp4Ot2OggrS6qIH26NSxJ/CWV4 D8/Hj2fikiQl3L2bLoNERFB0ATsLub2sZdDQKRqKmIypsOzPO0PeWAVVy FbLkej5gmnZDbS0UJKVFD7C0Gky5SxDJRq3UNvRR6K9VjV/5ulLJDuiiZ KYFyPJ7nOQ/3y/j4TVrb0V2APOqngaHii+nieHGzov79hH0dveRm5Xclw iZZDh+jNqzzsQg8PzCx/Ava3NcQ9wztvvDjmODrJmzcqUtK4rUGPtD7vn Q==; X-IronPort-AV: E=Sophos;i="5.88,211,1635199200"; d="scan'208";a="21092483" Received: from unknown (HELO tq-pgp-pr1.tq-net.de) ([192.168.6.15]) by mx1-pgp.tq-group.com with ESMTP; 16 Dec 2021 11:27:13 +0100 Received: from mx1.tq-group.com ([192.168.6.7]) by tq-pgp-pr1.tq-net.de (PGP Universal service); Thu, 16 Dec 2021 11:27:13 +0100 X-PGP-Universal: processed; by tq-pgp-pr1.tq-net.de on Thu, 16 Dec 2021 11:27:13 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tq-group.com; i=@tq-group.com; q=dns/txt; s=key1; t=1639650433; x=1671186433; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=f0fdQRX8De3W+inCWTedL31kMAynX9IsLrhxj70v9GQ=; b=L4Fut5/x+t/ayIakrNTYWVavgITC3vr4GGs/6os6rztmMBQ4o/1Y0GEM iJ/dLblE5+krxQTZs8dRoW/GpRiqfGoyk8tU8wQafARqpqeJbdTJy/T3P d4soxvy4g/RQlL4xBGFChgGXYuodh8aQ7J8bCXf+xoooPj0u6qifqmjGn zEXdTA7d6lkrkZL3FEg432pcFCo90dBxavJ8mtQDat7Sao8cMvKUk2xc+ wb4dmTvBRTb28kAPDRsRXo60YLLsrh2+ivE+ubE/TGrc40giEvjUnqdpO f5YRTOaJEbb0mlSg68H/uyundUxYczpbWisJ6JPaCXQMIr2dBAis+nsyZ A==; X-IronPort-AV: E=Sophos;i="5.88,211,1635199200"; d="scan'208";a="21092482" Received: from vtuxmail01.tq-net.de ([10.115.0.20]) by mx1.tq-group.com with ESMTP; 16 Dec 2021 11:27:13 +0100 Received: from localhost.localdomain (SCHIFFERM-M2.tq-net.de [10.121.201.15]) by vtuxmail01.tq-net.de (Postfix) with ESMTPA id C79BE280065; Thu, 16 Dec 2021 11:27:13 +0100 (CET) From: Matthias Schiffer To: u-boot@lists.denx.de Cc: Matthias Schiffer Subject: [PATCH] fastboot: only look up real partition names when no alias exists Date: Thu, 16 Dec 2021 11:26:38 +0100 Message-Id: <20211216102638.111391-1-matthias.schiffer@ew.tq-group.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.38 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean 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 Reviewed-by: Sean Anderson --- 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); } /**