Skip to content

Commit 3a434f6

Browse files
Dan Ehrenbergcomputersforpeace
authored andcommitted
mtd: part: Remove partition overlap checks
This patch makes MTD dynamic partitioning more flexible by removing overlap checks for dynamic partitions. I don't see any particular reason why overlapping dynamic partitions should be prohibited while static partitions are allowed to overlap freely. The checks previously had an off-by-one error, where 'end' should be one less than what it is currently set at, and adding partitions out of increasing order will fail. Disabling the checks resolves this issue. Signed-off-by: Dan Ehrenberg <[email protected]> Signed-off-by: Brian Norris <[email protected]>
1 parent a62c24d commit 3a434f6

File tree

1 file changed

+1
-20
lines changed

1 file changed

+1
-20
lines changed

drivers/mtd/mtdpart.c

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -582,8 +582,7 @@ int mtd_add_partition(struct mtd_info *master, const char *name,
582582
long long offset, long long length)
583583
{
584584
struct mtd_partition part;
585-
struct mtd_part *p, *new;
586-
uint64_t start, end;
585+
struct mtd_part *new;
587586
int ret = 0;
588587

589588
/* the direct offset is expected */
@@ -607,21 +606,7 @@ int mtd_add_partition(struct mtd_info *master, const char *name,
607606
if (IS_ERR(new))
608607
return PTR_ERR(new);
609608

610-
start = offset;
611-
end = offset + length;
612-
613609
mutex_lock(&mtd_partitions_mutex);
614-
list_for_each_entry(p, &mtd_partitions, list)
615-
if (p->master == master) {
616-
if ((start >= p->offset) &&
617-
(start < (p->offset + p->mtd.size)))
618-
goto err_inv;
619-
620-
if ((end >= p->offset) &&
621-
(end < (p->offset + p->mtd.size)))
622-
goto err_inv;
623-
}
624-
625610
list_add(&new->list, &mtd_partitions);
626611
mutex_unlock(&mtd_partitions_mutex);
627612

@@ -630,10 +615,6 @@ int mtd_add_partition(struct mtd_info *master, const char *name,
630615
mtd_add_partition_attrs(new);
631616

632617
return ret;
633-
err_inv:
634-
mutex_unlock(&mtd_partitions_mutex);
635-
free_partition(new);
636-
return -EINVAL;
637618
}
638619
EXPORT_SYMBOL_GPL(mtd_add_partition);
639620

0 commit comments

Comments
 (0)