From: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Date: Sat, 26 Aug 2023 01:53:41 +0000 (+0200)
Subject: cmd: fix gpt setenv
X-Git-Tag: v2025.01-rc5-pxa1908~871^2~7
X-Git-Url: http://git.dujemihanovic.xyz/img/html/static/gitweb.css?a=commitdiff_plain;h=018346770b04e32caf75d5730301f3ba52ed005f;p=u-boot.git

cmd: fix gpt setenv

Do not assume that partitions are continuously numbered starting at 1.

Having a partition table with a single partition 63 is valid.

Fixes: 12fc1f3bb223 ("cmd: gpt: add eMMC and GPT support")
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
---

diff --git a/cmd/gpt.c b/cmd/gpt.c
index 007a68eaa7..d0e165d539 100644
--- a/cmd/gpt.c
+++ b/cmd/gpt.c
@@ -786,10 +786,8 @@ static int gpt_setenv(struct blk_desc *desc, const char *name)
 
 		for (i = 1; i < part_drv->max_entries; i++) {
 			ret = part_drv->get_info(desc, i, &pinfo);
-			if (ret) {
-				/* no more entries in table */
-				break;
-			}
+			if (ret)
+				continue;
 
 			if (!strcmp(name, (const char *)pinfo.name)) {
 				/* match found, setup environment variables */