Commit a02820fc authored by Boris Brezillon's avatar Boris Brezillon Committed by Jagan Teki

mtd: Delete partitions attached to the device when a device is deleted

If we don't do that, partitions might still be exposed while the
underlying device is gone.

Fixes: 2a74930d ("mtd: mtdpart: implement proper partition handling")
Signed-off-by: default avatarBoris Brezillon <>
Tested-by: Heiko Schocher's avatarHeiko Schocher <>
parent 779c9c05
......@@ -528,6 +528,13 @@ int del_mtd_device(struct mtd_info *mtd)
struct mtd_notifier *not;
ret = del_mtd_partitions(mtd);
if (ret) {
debug("Failed to delete MTD partitions attached to %s (err %d)\n",
mtd->name, ret);
return ret;
if (idr_find(&mtd_idr, mtd->index) != mtd) {
......@@ -562,8 +562,23 @@ unsigned mtd_mmap_capabilities(struct mtd_info *mtd);
/* drivers/mtd/mtdcore.h */
int add_mtd_device(struct mtd_info *mtd);
int del_mtd_device(struct mtd_info *mtd);
int add_mtd_partitions(struct mtd_info *, const struct mtd_partition *, int);
int del_mtd_partitions(struct mtd_info *);
static inline int add_mtd_partitions(struct mtd_info *mtd,
const struct mtd_partition *parts,
int nparts)
return 0;
static inline int del_mtd_partitions(struct mtd_info *mtd)
return 0;
struct mtd_info *__mtd_next_device(int i);
#define mtd_for_each_device(mtd) \
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment