Skip to content

Commit 9a797e0

Browse files
neosys007gregkh
authored andcommitted
mtd: mtdswap: remove debugfs stats file on teardown
[ Upstream commit 66fb313 ] mtdswap_add_debugfs() creates an mtdswap_stats debugfs file under the per-MTD debugfs directory, but mtdswap_remove_dev() never removes it before freeing the mtdswap_dev. Store the returned dentry and remove it during device teardown before the driver-private state is freed. Fixes: a321590 ("mtd: Add mtdswap block driver") Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent dfa535c commit 9a797e0

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

drivers/mtd/mtdswap.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ struct mtdswap_dev {
125125

126126
char *page_buf;
127127
char *oob_buf;
128+
struct dentry *debugfs_stats;
128129
};
129130

130131
struct mtdswap_oobdata {
@@ -1262,7 +1263,8 @@ static int mtdswap_add_debugfs(struct mtdswap_dev *d)
12621263
if (IS_ERR_OR_NULL(root))
12631264
return -1;
12641265

1265-
debugfs_create_file("mtdswap_stats", S_IRUSR, root, d, &mtdswap_fops);
1266+
d->debugfs_stats = debugfs_create_file("mtdswap_stats", 0400, root,
1267+
d, &mtdswap_fops);
12661268

12671269
return 0;
12681270
}
@@ -1463,6 +1465,7 @@ static void mtdswap_remove_dev(struct mtd_blktrans_dev *dev)
14631465
{
14641466
struct mtdswap_dev *d = MTDSWAP_MBD_TO_MTDSWAP(dev);
14651467

1468+
debugfs_remove(d->debugfs_stats);
14661469
del_mtd_blktrans_dev(dev);
14671470
mtdswap_cleanup(d);
14681471
kfree(d);

0 commit comments

Comments
 (0)