mtd: part: Remove partition overlap checks
Linux-MTD Mailing List
linux-mtd at lists.infradead.org
Wed Apr 22 10:59:07 PDT 2015
Gitweb: http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=3a434f66e6dab645d74a59c95651cdbe16497a50
Commit: 3a434f66e6dab645d74a59c95651cdbe16497a50
Parent: a62c24d75529118d10c45350c3b75715d52ff574
Author: Dan Ehrenberg <dehrenberg at chromium.org>
AuthorDate: Thu Apr 2 15:15:12 2015 -0700
Committer: Brian Norris <computersforpeace at gmail.com>
CommitDate: Sun Apr 5 17:44:03 2015 -0700
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 <dehrenberg at chromium.org>
Signed-off-by: Brian Norris <computersforpeace at gmail.com>
---
drivers/mtd/mtdpart.c | 21 +--------------------
1 file changed, 1 insertion(+), 20 deletions(-)
diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c
index be80340..cafdb88 100644
--- a/drivers/mtd/mtdpart.c
+++ b/drivers/mtd/mtdpart.c
@@ -582,8 +582,7 @@ int mtd_add_partition(struct mtd_info *master, const char *name,
long long offset, long long length)
{
struct mtd_partition part;
- struct mtd_part *p, *new;
- uint64_t start, end;
+ struct mtd_part *new;
int ret = 0;
/* the direct offset is expected */
@@ -607,21 +606,7 @@ int mtd_add_partition(struct mtd_info *master, const char *name,
if (IS_ERR(new))
return PTR_ERR(new);
- start = offset;
- end = offset + length;
-
mutex_lock(&mtd_partitions_mutex);
- list_for_each_entry(p, &mtd_partitions, list)
- if (p->master == master) {
- if ((start >= p->offset) &&
- (start < (p->offset + p->mtd.size)))
- goto err_inv;
-
- if ((end >= p->offset) &&
- (end < (p->offset + p->mtd.size)))
- goto err_inv;
- }
-
list_add(&new->list, &mtd_partitions);
mutex_unlock(&mtd_partitions_mutex);
@@ -630,10 +615,6 @@ int mtd_add_partition(struct mtd_info *master, const char *name,
mtd_add_partition_attrs(new);
return ret;
-err_inv:
- mutex_unlock(&mtd_partitions_mutex);
- free_partition(new);
- return -EINVAL;
}
EXPORT_SYMBOL_GPL(mtd_add_partition);
More information about the linux-mtd-cvs
mailing list