[PATCH 3.16 141/294] mtd: nandsim: remove debugfs entries in error path

From: Ben Hutchings
Date: Mon Nov 06 2017 - 19:18:07 EST


3.16.50-rc1 review patch. If anyone has any objections, please let me know.

------------------

From: Uwe Kleine-KÃnig <u.kleine-koenig@xxxxxxxxxxxxxx>

commit b974696da1cfc5aa0c29ed97dc8f6c239899e64b upstream.

The debugfs entries must be removed before an error is returned in the
probe function. Otherwise another try to load the module fails and when
the debugfs files are accessed without the module loaded, the kernel
still tries to call a function in that module.

Fixes: 5346c27c5fed ("mtd: nandsim: Introduce debugfs infrastructure")
Signed-off-by: Uwe Kleine-KÃnig <u.kleine-koenig@xxxxxxxxxxxxxx>
Reviewed-by: Richard Weinberger <richard@xxxxxx>
Acked-by: Boris Brezillon <boris.brezillon@xxxxxxxxxxxxxxxxxx>
Signed-off-by: Brian Norris <computersforpeace@xxxxxxxxx>
Signed-off-by: Ben Hutchings <ben@xxxxxxxxxxxxxxx>
---
drivers/mtd/nand/nandsim.c | 1 +
1 file changed, 1 insertion(+)

--- a/drivers/mtd/nand/nandsim.c
+++ b/drivers/mtd/nand/nandsim.c
@@ -2387,6 +2387,7 @@ static int __init ns_init_module(void)
return 0;

err_exit:
+ nandsim_debugfs_remove(nand);
free_nandsim(nand);
nand_release(nsmtd);
for (i = 0;i < ARRAY_SIZE(nand->partitions); ++i)