[PATCH 1/2] devfs: take into account for the partitions check that mtd is different
Sascha Hauer
sha at pengutronix.de
Mon Jul 11 03:31:58 PDT 2022
On Mon, Jul 11, 2022 at 11:09:14AM +0200, Uwe Kleine-König wrote:
> mtd partitions are separate devices. Their partition info is relative to
> these subdevices and so offset is 0 for them. This needs to be taken
> into account for the overlap check.
>
> Fixes: 7f9f45b9bfef ("devfs: Do not create overlapping partitions")
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig at pengutronix.de>
> ---
> fs/devfs-core.c | 15 +++++++++++++--
> 1 file changed, 13 insertions(+), 2 deletions(-)
Applied, thanks
Sascha
>
> diff --git a/fs/devfs-core.c b/fs/devfs-core.c
> index 38423e5d1e07..dca5e10191d4 100644
> --- a/fs/devfs-core.c
> +++ b/fs/devfs-core.c
> @@ -395,9 +395,20 @@ static bool region_overlap(loff_t starta, loff_t lena,
> static int check_overlap(struct cdev *cdev, const char *name, loff_t offset, loff_t size)
> {
> struct cdev *cpart;
> + loff_t cpart_offset;
>
> list_for_each_entry(cpart, &cdev->partitions, partition_entry) {
> - if (region_overlap(cpart->offset, cpart->size,
> + cpart_offset = cpart->offset;
> +
> + /*
> + * An mtd partition is represented by a separate cdev and its
> + * cpart is relative to this one. So its .offset is 0 and we
> + * have to consult .master_offset to get its offset.
> + */
> + if (cpart->mtd)
> + cpart_offset = cpart->mtd->master_offset;
> +
> + if (region_overlap(cpart_offset, cpart->size,
> offset, size))
> goto conflict;
> }
> @@ -408,7 +419,7 @@ conflict:
> pr_err("New partition %s (0x%08llx-0x%08llx) on %s "
> "overlaps with partition %s (0x%08llx-0x%08llx), not creating it\n",
> name, offset, offset + size - 1, cpart->name,
> - cpart->name, cpart->offset, cpart->offset + cpart->size - 1);
> + cpart->name, cpart_offset, cpart_offset + cpart->size - 1);
>
> return -EINVAL;
> }
> --
> 2.36.1
>
>
>
--
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 |
More information about the barebox
mailing list