diff options
-rw-r--r-- | drivers/mtd/mtdchar.c | 8 | ||||
-rw-r--r-- | drivers/mtd/mtdpart.c | 10 | ||||
-rw-r--r-- | include/linux/mtd/partitions.h | 2 |
3 files changed, 10 insertions, 10 deletions
diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c index cad8fcc7b239..16de17b5b829 100644 --- a/drivers/mtd/mtdchar.c +++ b/drivers/mtd/mtdchar.c | |||
@@ -522,10 +522,6 @@ static int mtd_blkpg_ioctl(struct mtd_info *mtd, | |||
522 | if (!capable(CAP_SYS_ADMIN)) | 522 | if (!capable(CAP_SYS_ADMIN)) |
523 | return -EPERM; | 523 | return -EPERM; |
524 | 524 | ||
525 | /* Only master mtd device must be used to control partitions */ | ||
526 | if (!mtd_is_master(mtd)) | ||
527 | return -EINVAL; | ||
528 | |||
529 | if (copy_from_user(&a, arg, sizeof(struct blkpg_ioctl_arg))) | 525 | if (copy_from_user(&a, arg, sizeof(struct blkpg_ioctl_arg))) |
530 | return -EFAULT; | 526 | return -EFAULT; |
531 | 527 | ||
@@ -535,6 +531,10 @@ static int mtd_blkpg_ioctl(struct mtd_info *mtd, | |||
535 | switch (a.op) { | 531 | switch (a.op) { |
536 | case BLKPG_ADD_PARTITION: | 532 | case BLKPG_ADD_PARTITION: |
537 | 533 | ||
534 | /* Only master mtd device must be used to add partitions */ | ||
535 | if (mtd_is_partition(mtd)) | ||
536 | return -EINVAL; | ||
537 | |||
538 | return mtd_add_partition(mtd, p.devname, p.start, p.length); | 538 | return mtd_add_partition(mtd, p.devname, p.start, p.length); |
539 | 539 | ||
540 | case BLKPG_DEL_PARTITION: | 540 | case BLKPG_DEL_PARTITION: |
diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c index 79e3689f1e16..1047ff0a4f55 100644 --- a/drivers/mtd/mtdpart.c +++ b/drivers/mtd/mtdpart.c | |||
@@ -720,19 +720,19 @@ int parse_mtd_partitions(struct mtd_info *master, const char **types, | |||
720 | } | 720 | } |
721 | EXPORT_SYMBOL_GPL(parse_mtd_partitions); | 721 | EXPORT_SYMBOL_GPL(parse_mtd_partitions); |
722 | 722 | ||
723 | int mtd_is_master(struct mtd_info *mtd) | 723 | int mtd_is_partition(struct mtd_info *mtd) |
724 | { | 724 | { |
725 | struct mtd_part *part; | 725 | struct mtd_part *part; |
726 | int nopart = 0; | 726 | int ispart = 0; |
727 | 727 | ||
728 | mutex_lock(&mtd_partitions_mutex); | 728 | mutex_lock(&mtd_partitions_mutex); |
729 | list_for_each_entry(part, &mtd_partitions, list) | 729 | list_for_each_entry(part, &mtd_partitions, list) |
730 | if (&part->mtd == mtd) { | 730 | if (&part->mtd == mtd) { |
731 | nopart = 1; | 731 | ispart = 1; |
732 | break; | 732 | break; |
733 | } | 733 | } |
734 | mutex_unlock(&mtd_partitions_mutex); | 734 | mutex_unlock(&mtd_partitions_mutex); |
735 | 735 | ||
736 | return nopart; | 736 | return ispart; |
737 | } | 737 | } |
738 | EXPORT_SYMBOL_GPL(mtd_is_master); | 738 | EXPORT_SYMBOL_GPL(mtd_is_partition); |
diff --git a/include/linux/mtd/partitions.h b/include/linux/mtd/partitions.h index 2b54316591d2..4a0a8ba90a72 100644 --- a/include/linux/mtd/partitions.h +++ b/include/linux/mtd/partitions.h | |||
@@ -89,7 +89,7 @@ static inline int mtd_has_cmdlinepart(void) { return 1; } | |||
89 | static inline int mtd_has_cmdlinepart(void) { return 0; } | 89 | static inline int mtd_has_cmdlinepart(void) { return 0; } |
90 | #endif | 90 | #endif |
91 | 91 | ||
92 | int mtd_is_master(struct mtd_info *mtd); | 92 | int mtd_is_partition(struct mtd_info *mtd); |
93 | int mtd_add_partition(struct mtd_info *master, char *name, | 93 | int mtd_add_partition(struct mtd_info *master, char *name, |
94 | long long offset, long long length); | 94 | long long offset, long long length); |
95 | int mtd_del_partition(struct mtd_info *master, int partno); | 95 | int mtd_del_partition(struct mtd_info *master, int partno); |