From: Mikhail Kshevetskiy Date: Mon, 19 Jan 2026 22:33:04 +0000 (+0300) Subject: cmd: gpt: fix partition search boundaries X-Git-Tag: v2026.04-rc2~22^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6a1f8c897375d1f673699efdb3664b96f5af8c1c;p=thirdparty%2Fu-boot.git cmd: gpt: fix partition search boundaries GPT disk partition with max available number (ex: /dev/mmcblk128) can't be used from U-Boot. Here is an example: => mmc part Partition Map for mmc device 0 -- Partition Type: EFI Part Start LBA End LBA Name Attributes Type GUID Partition GUID 1 0x00001000 0x000013ff "env1" attrs: 0x0000000000000000 type: 0fc63daf-8483-4772-8e79-3d69d8477de4 guid: 5452574f-2211-4433-5566-778899aabb02 2 0x00001400 0x000017ff "env2" attrs: 0x0000000000000000 type: 0fc63daf-8483-4772-8e79-3d69d8477de4 guid: 5452574f-2211-4433-5566-778899aabb03 ................. 8 0x00158000 0x0034bfff "apps" attrs: 0x0000000000000000 type: 0fc63daf-8483-4772-8e79-3d69d8477de4 guid: 5452574f-2211-4433-5566-778899aabb09 128 0x00000420 0x00000fff "fip" attrs: 0x0000000000000000 type: c12a7328-f81f-11d2-ba4b-00a0c93ec93b guid: 5452574f-2211-4433-5566-778899aabb01 => gpt setenv mmc 0 fip error! => gpt setenv mmc 0 apps success! The error is caused by invalid boundary checks. This patch fixes an issue. Fixes: 12fc1f3bb223 ("cmd: gpt: add eMMC and GPT support") Signed-off-by: Mikhail Kshevetskiy Acked-by: Quentin Schulz --- diff --git a/cmd/gpt.c b/cmd/gpt.c index 84221881c39..205f696c807 100644 --- a/cmd/gpt.c +++ b/cmd/gpt.c @@ -723,7 +723,7 @@ static int gpt_enumerate(struct blk_desc *desc) if (part_drv->test(desc)) continue; - for (i = 1; i < part_drv->max_entries; i++) { + for (i = 1; i <= part_drv->max_entries; i++) { ret = part_driver_get_info(part_drv, desc, i, &pinfo); if (ret) continue; @@ -819,7 +819,7 @@ static int gpt_setenv(struct blk_desc *desc, const char *name) struct disk_partition pinfo; int i; - for (i = 1; i < part_drv->max_entries; i++) { + for (i = 1; i <= part_drv->max_entries; i++) { ret = part_driver_get_info(part_drv, desc, i, &pinfo); if (ret) continue;