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....@mediatek.com>

Reported-by: Francesco Dolcini <france...@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

Attachment: signature.asc
Description: PGP signature

Reply via email to