* [PATCH] mtd: mtdswap: remove debugfs stats file on teardown
@ 2026-06-15 9:08 Pengpeng Hou
2026-06-22 9:19 ` Miquel Raynal
0 siblings, 1 reply; 2+ messages in thread
From: Pengpeng Hou @ 2026-06-15 9:08 UTC (permalink / raw)
To: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra, linux-mtd,
linux-kernel
Cc: Pengpeng Hou
mtdswap_add_debugfs() publishes mtdswap_stats with struct mtdswap_dev as
its private data. mtdswap_remove_dev() deletes the block translation
device and frees that private data, but it does not remove the debugfs
file.
Keep the debugfs dentry and remove it before freeing the mtdswap device
state.
Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
---
drivers/mtd/mtdswap.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/mtd/mtdswap.c b/drivers/mtd/mtdswap.c
index 866933fc8426..844d75ba05f3 100644
--- a/drivers/mtd/mtdswap.c
+++ b/drivers/mtd/mtdswap.c
@@ -101,6 +101,7 @@ struct mtdswap_dev {
struct mtd_blktrans_dev *mbd_dev;
struct mtd_info *mtd;
struct device *dev;
+ struct dentry *debugfs_stats;
unsigned int *page_data;
unsigned int *revmap;
@@ -1262,7 +1263,8 @@ static int mtdswap_add_debugfs(struct mtdswap_dev *d)
if (IS_ERR_OR_NULL(root))
return -1;
- debugfs_create_file("mtdswap_stats", S_IRUSR, root, d, &mtdswap_fops);
+ d->debugfs_stats = debugfs_create_file("mtdswap_stats", 0400,
+ root, d, &mtdswap_fops);
return 0;
}
@@ -1463,6 +1465,8 @@ static void mtdswap_remove_dev(struct mtd_blktrans_dev *dev)
{
struct mtdswap_dev *d = MTDSWAP_MBD_TO_MTDSWAP(dev);
+ if (!IS_ERR_OR_NULL(d->debugfs_stats))
+ debugfs_remove(d->debugfs_stats);
del_mtd_blktrans_dev(dev);
mtdswap_cleanup(d);
kfree(d);
--
2.50.1 (Apple Git-155)
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] mtd: mtdswap: remove debugfs stats file on teardown
2026-06-15 9:08 [PATCH] mtd: mtdswap: remove debugfs stats file on teardown Pengpeng Hou
@ 2026-06-22 9:19 ` Miquel Raynal
0 siblings, 0 replies; 2+ messages in thread
From: Miquel Raynal @ 2026-06-22 9:19 UTC (permalink / raw)
To: Pengpeng Hou
Cc: Richard Weinberger, Vignesh Raghavendra, linux-mtd, linux-kernel
Hello,
> @@ -1463,6 +1465,8 @@ static void mtdswap_remove_dev(struct mtd_blktrans_dev *dev)
> {
> struct mtdswap_dev *d = MTDSWAP_MBD_TO_MTDSWAP(dev);
>
> + if (!IS_ERR_OR_NULL(d->debugfs_stats))
> + debugfs_remove(d->debugfs_stats);
Please check debugfs_remove() implementation, the 'if' condition
is already handled and therefore does not need to be done here.
Thanks,
Miquèl
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-06-22 9:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-15 9:08 [PATCH] mtd: mtdswap: remove debugfs stats file on teardown Pengpeng Hou
2026-06-22 9:19 ` Miquel Raynal
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox