[PATCH] mtd: mtdparts: calculate mtd partition offset before calculating size
Tom Rini
trini at konsulko.com
Fri Apr 25 16:19:37 CEST 2025
On Fri, Apr 25, 2025 at 11:43:03AM +0800, Weijie Gao wrote:
> The mtd partition offset must be calculated first as it will be
> referenced when calculating the mtd partition size.
>
> Change-Id: Iccfd101b0a9597ac240c25670da638a82af28980
> Fixes: 1ca97ee9039 (mtd: mtdpart: Support MTD_SIZE_REMAINING with unallocated memory area)
> Signed-off-by: Weijie Gao <weijie.gao at mediatek.com>
Reported-by: Francesco Dolcini <francesco at dolcini.it>
> ---
> drivers/mtd/mtdpart.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c
> index 3f8edeb5093..99bea6f1c85 100644
> --- a/drivers/mtd/mtdpart.c
> +++ b/drivers/mtd/mtdpart.c
> @@ -236,6 +236,10 @@ int mtd_parse_partitions(struct mtd_info *parent, const char **_mtdparts,
> if (ret)
> return ret;
>
> + if (parts[idx].offset == MTD_OFFSET_NOT_SPECIFIED)
> + parts[idx].offset = cur_off;
> + cur_off += parts[idx].size;
> +
> if (parts[idx].size == MTD_SIZE_REMAINING)
> parts[idx].size = parent->size - parts[idx].offset;
>
> @@ -246,10 +250,6 @@ int mtd_parse_partitions(struct mtd_info *parent, const char **_mtdparts,
> return -EINVAL;
> }
>
> - if (parts[idx].offset == MTD_OFFSET_NOT_SPECIFIED)
> - parts[idx].offset = cur_off;
> - cur_off += parts[idx].size;
> -
> parts[idx].ecclayout = parent->ecclayout;
> }
>
> --
> 2.34.1
>
--
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20250425/924de8cc/attachment.sig>
More information about the U-Boot
mailing list