[PATCH v2] cache: sifive_ccache: remove debugfs on driver register failure
From: Pengpeng Hou
Date: Mon Jun 22 2026 - 21:56:28 EST
sifive_ccache_init() sets up debugfs entries before registering the
platform driver. If platform_driver_register() fails, the current error
path unmaps the controller base but leaves the debugfs directory behind.
Remove the debugfs directory directly on that failure path before
unmapping the controller base.
Fixes: c90847bcbfb6 ("cache: sifive_ccache: Partially convert to a platform driver")
Signed-off-by: Pengpeng Hou <pengpeng@xxxxxxxxxxx>
---
Changes since v1: https://lore.kernel.org/all/20260616151314.87102-1-pengpeng@xxxxxxxxxxx/
- remove the helper and explicit dentry NULL assignment
- directly call debugfs_remove_recursive() in the
platform_driver_register() failure path
drivers/cache/sifive_ccache.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/cache/sifive_ccache.c b/drivers/cache/sifive_ccache.c
index 2acb8bdf06d5..3b7a78fc7feb 100644
--- a/drivers/cache/sifive_ccache.c
+++ b/drivers/cache/sifive_ccache.c
@@ -338,12 +338,16 @@ static int __init sifive_ccache_init(void)
rc = platform_driver_register(&sifive_ccache_driver);
if (rc)
- goto err_unmap;
+ goto err_remove_debugfs;
of_node_put(np);
return 0;
+err_remove_debugfs:
+#ifdef CONFIG_DEBUG_FS
+ debugfs_remove_recursive(sifive_test);
+#endif
err_unmap:
iounmap(ccache_base);
err_node_put:
--
2.50.1 (Apple Git-155)