linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mtd: core: don't remove debugfs directory if device is in use
@ 2021-10-14 20:39 Zev Weiss
  2021-10-15 10:31 ` Miquel Raynal
  0 siblings, 1 reply; 2+ messages in thread
From: Zev Weiss @ 2021-10-14 20:39 UTC (permalink / raw)
  To: linux-mtd
  Cc: Zev Weiss, Miquel Raynal, Richard Weinberger,
	Vignesh Raghavendra, Michael Walle, Zhen Lei, Lee Jones,
	Tian Tao, Jon Hunter, Petr Malat, Brian Norris, Boris Brezillon,
	Mario Rugiero, linux-kernel

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: e8e3edb95ce6 ("mtd: create per-device and module-scope debugfs entries")
Signed-off-by: Zev Weiss <zev@bewilderbeest.net>
---
 drivers/mtd/mtdcore.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index e22266f63ae9..0a0fca737d43 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -724,8 +724,6 @@ int del_mtd_device(struct mtd_info *mtd)
 
 	mutex_lock(&mtd_table_mutex);
 
-	debugfs_remove_recursive(mtd->dbg.dfs_dir);
-
 	if (idr_find(&mtd_idr, mtd->index) != mtd) {
 		ret = -ENODEV;
 		goto out_error;
@@ -741,6 +739,8 @@ int del_mtd_device(struct mtd_info *mtd)
 		       mtd->index, mtd->name, mtd->usecount);
 		ret = -EBUSY;
 	} else {
+		debugfs_remove_recursive(mtd->dbg.dfs_dir);
+
 		/* Try to remove the NVMEM provider */
 		if (mtd->nvmem)
 			nvmem_unregister(mtd->nvmem);
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] mtd: core: don't remove debugfs directory if device is in use
  2021-10-14 20:39 [PATCH] mtd: core: don't remove debugfs directory if device is in use Zev Weiss
@ 2021-10-15 10:31 ` Miquel Raynal
  0 siblings, 0 replies; 2+ messages in thread
From: Miquel Raynal @ 2021-10-15 10:31 UTC (permalink / raw)
  To: Zev Weiss, linux-mtd
  Cc: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
	Michael Walle, Zhen Lei, Lee Jones, Tian Tao, Jon Hunter,
	Petr Malat, Brian Norris, Boris Brezillon, Mario Rugiero,
	linux-kernel

On Thu, 2021-10-14 at 20:39:52 UTC, Zev Weiss wrote:
> 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: e8e3edb95ce6 ("mtd: create per-device and module-scope debugfs entries")
> Signed-off-by: Zev Weiss <zev@bewilderbeest.net>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/next, thanks.

Miquel

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-10-15 10:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-14 20:39 [PATCH] mtd: core: don't remove debugfs directory if device is in use Zev Weiss
2021-10-15 10:31 ` Miquel Raynal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).