mtd: core: don't remove debugfs directory if device is in use
authorZev Weiss <zev@bewilderbeest.net>
Thu, 14 Oct 2021 20:39:52 +0000 (13:39 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 18 Nov 2021 13:04:23 +0000 (14:04 +0100)
commit36104e1f71ddb0fb39c49a7bbc375894085acb26
tree7f27eee92eaa7f5621327fc3e3c84b346893d56e
parent0b73c025bfcf462b467ec176ddbcbbb47efdef8a
mtd: core: don't remove debugfs directory if device is in use

[ Upstream commit c13de2386c78e890d4ae6f01a85eefd0b293fb08 ]

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>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20211014203953.5424-1-zev@bewilderbeest.net
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/mtd/mtdcore.c