mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH] partitions: efi: only warn about valid GPT entries beyond the limit
Date: Wed, 26 Aug 2026 11:39:36 +0200	[thread overview]
Message-ID: <20260826093936.2542278-1-a.fatoum@pengutronix.de> (raw)

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@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




             reply	other threads:[~2026-08-26  9:40 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-26  9:39 Ahmad Fatoum [this message]
2026-08-28 13:00 ` Sascha Hauer

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=20260826093936.2542278-1-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox