[PATCH] partitions: efi: only warn about valid GPT entries beyond the limit
Ahmad Fatoum
a.fatoum at pengutronix.de
Wed Aug 26 02:39:36 PDT 2026
GPT headers may describe more than the customary 128 partition entries.
xorriso for example writes a 248 entry table for hybrid ISOs like the
Alpine Linux images, of which only three entries are in use. barebox
would then warn on every boot:
WARNING: GPT has more partitions than we support (248) > max partition number (128)
although it could handle every partition that actually exists. Iterate
over all entries instead and only warn about the valid ones that we
have to ignore.
Assisted-by: Claude:fable-5
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
common/partitions/efi.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/common/partitions/efi.c b/common/partitions/efi.c
index 7ec54a98e335..d9f0e1a00d45 100644
--- a/common/partitions/efi.c
+++ b/common/partitions/efi.c
@@ -626,12 +626,6 @@ static struct partition_desc *efi_partition(void *buf, struct block_device *blk)
nb_part = le32_to_cpu(gpt->num_partition_entries);
- if (nb_part > MAX_PARTITION) {
- dev_warn(blk->dev, "GPT has more partitions than we support (%d) > max partition number (%d)\n",
- nb_part, MAX_PARTITION);
- nb_part = MAX_PARTITION;
- }
-
snprintf(blk->cdev.diskuuid, sizeof(blk->cdev.diskuuid), "%pUl", &gpt->disk_guid);
add_gpt_diskuuid_param(epd, blk);
@@ -641,6 +635,12 @@ static struct partition_desc *efi_partition(void *buf, struct block_device *blk)
continue;
}
+ if (i >= MAX_PARTITION) {
+ dev_warn(blk->dev, "ignoring GPT partition %d beyond the %d we support\n",
+ i + 1, MAX_PARTITION);
+ continue;
+ }
+
epart = xzalloc(sizeof(*epart));
epart->pte = &ptes[i];
pentry = &epart->part;
--
2.47.3
More information about the barebox
mailing list