mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: Sascha Hauer <s.hauer@pengutronix.de>,
	Barebox List <barebox@lists.infradead.org>
Subject: Re: [PATCH 2/2] partitions: efi: Fix MAX_PARTITION check
Date: Wed, 2 Jun 2021 11:17:08 +0200	[thread overview]
Message-ID: <49735235-eb7b-00e4-7f5a-41ec5c3a1080@pengutronix.de> (raw)
In-Reply-To: <20210602071533.10093-2-s.hauer@pengutronix.de>



On 02.06.21 09:15, Sascha Hauer wrote:
> The GPT partiton parser has a check which should check if the GPT has
> more partitions than we support. This doesn't work because the loop
> iterating over the partitions exits with a maximum i of MAX_PARTITION,
> i > MAX_PARTITION will never be true. Fix the check.
> 
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>

Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de>

> ---
>  common/partitions/efi.c | 13 ++++++++-----
>  1 file changed, 8 insertions(+), 5 deletions(-)
> 
> diff --git a/common/partitions/efi.c b/common/partitions/efi.c
> index 437c3d64f8..135b08901a 100644
> --- a/common/partitions/efi.c
> +++ b/common/partitions/efi.c
> @@ -446,7 +446,14 @@ static void efi_partition(void *buf, struct block_device *blk,
>  	}
>  
>  	nb_part = le32_to_cpu(gpt->num_partition_entries);
> -	for (i = 0; i < MAX_PARTITION && i < nb_part; i++) {
> +
> +	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;
> +	}
> +
> +	for (i = 0; i < nb_part; i++) {
>  		if (!is_pte_valid(&ptes[i], last_lba(blk))) {
>  			dev_dbg(blk->dev, "Invalid pte %d\n", i);
>  			return;
> @@ -460,10 +467,6 @@ static void efi_partition(void *buf, struct block_device *blk,
>  		snprintf(pentry->partuuid, sizeof(pentry->partuuid), "%pUl", &ptes[i].unique_partition_guid);
>  		pd->used_entries++;
>  	}
> -
> -	if (i > MAX_PARTITION)
> -		dev_warn(blk->dev, "num_partition_entries (%d) > max partition number (%d)\n",
> -			 nb_part, MAX_PARTITION);
>  }
>  
>  static struct partition_parser efi_partition_parser = {
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


  reply	other threads:[~2021-06-02  9:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-02  7:15 [PATCH 1/2] partitions: Increase MAX_PARTITION to 128 Sascha Hauer
2021-06-02  7:15 ` [PATCH 2/2] partitions: efi: Fix MAX_PARTITION check Sascha Hauer
2021-06-02  9:17   ` Ahmad Fatoum [this message]
2021-06-02  9:20 ` [PATCH 1/2] partitions: Increase MAX_PARTITION to 128 Ahmad Fatoum

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=49735235-eb7b-00e4-7f5a-41ec5c3a1080@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=s.hauer@pengutronix.de \
    --subject='Re: [PATCH 2/2] partitions: efi: Fix MAX_PARTITION check' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox