Skip to content

Commit c13de23

Browse files
zevweissmiquelraynal
authored andcommitted
mtd: core: don't remove debugfs directory if device is in use
Previously, if del_mtd_device() failed with -EBUSY due to a non-zero usecount, a subsequent call to attempt the deletion again would try to remove a debugfs directory that had already been removed and panic. With this change the second call can instead proceed safely. Fixes: e8e3edb ("mtd: create per-device and module-scope debugfs entries") Signed-off-by: Zev Weiss <[email protected]> Signed-off-by: Miquel Raynal <[email protected]> Link: https://lore.kernel.org/linux-mtd/[email protected]
1 parent 8a057b5 commit c13de23

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/mtd/mtdcore.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -724,8 +724,6 @@ int del_mtd_device(struct mtd_info *mtd)
724724

725725
mutex_lock(&mtd_table_mutex);
726726

727-
debugfs_remove_recursive(mtd->dbg.dfs_dir);
728-
729727
if (idr_find(&mtd_idr, mtd->index) != mtd) {
730728
ret = -ENODEV;
731729
goto out_error;
@@ -741,6 +739,8 @@ int del_mtd_device(struct mtd_info *mtd)
741739
mtd->index, mtd->name, mtd->usecount);
742740
ret = -EBUSY;
743741
} else {
742+
debugfs_remove_recursive(mtd->dbg.dfs_dir);
743+
744744
/* Try to remove the NVMEM provider */
745745
if (mtd->nvmem)
746746
nvmem_unregister(mtd->nvmem);

0 commit comments

Comments
 (0)