Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] soc: amlogic: meson-clk-measure: fix debugfs directory leak on unbind
@ 2026-06-02  3:52 Yi Ding
  0 siblings, 0 replies; only message in thread
From: Yi Ding @ 2026-06-02  3:52 UTC (permalink / raw)
  To: Neil Armstrong, Kevin Hilman
  Cc: Jerome Brunet, Martin Blumenstingl, linux-arm-kernel,
	linux-amlogic, linux-kernel, Yi Ding

meson_msr_probe() creates the "meson-clk-msr" debugfs directory (and its
"clks" subdirectory) but keeps the dentry only in a local variable, and
the driver has no remove callback. As it is registered with
module_platform_driver(), unbinding or unloading the driver leaks the
whole debugfs tree, and a subsequent probe then collides with the
already-existing "meson-clk-msr" directory.

Register a devm action that calls debugfs_remove_recursive() on the root
dentry when the device is unbound, tearing down the directory, its "clks"
subdirectory and all files.

Fixes: 2b45ebef39a2 ("soc: amlogic: Add Meson Clock Measure driver")
Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Yi Ding <yi.s.ding@gmail.com>
---
Reproduced on an ODROID-N2 (Amlogic S922X, G12B), v6.18: the
"meson-clk-msr" debugfs directory survives an unbind, and rebinding the
device then warns:

  # echo ffd18000.clock-measure > /sys/bus/platform/drivers/meson_msr/unbind
  # echo ffd18000.clock-measure > /sys/bus/platform/drivers/meson_msr/bind
  debugfs: 'meson-clk-msr' already exists in '/'

 drivers/soc/amlogic/meson-clk-measure.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/soc/amlogic/meson-clk-measure.c b/drivers/soc/amlogic/meson-clk-measure.c
index d862e30a2..1bcaac7b7 100644
--- a/drivers/soc/amlogic/meson-clk-measure.c
+++ b/drivers/soc/amlogic/meson-clk-measure.c
@@ -902,6 +902,11 @@ static struct regmap_config meson_clk_msr_regmap_config = {
 	.reg_stride = 4,
 };
 
+static void meson_msr_debugfs_remove(void *data)
+{
+	debugfs_remove_recursive(data);
+}
+
 static int meson_msr_probe(struct platform_device *pdev)
 {
 	const struct meson_msr_data *match_data;
@@ -967,7 +972,8 @@ static int meson_msr_probe(struct platform_device *pdev)
 				    &priv->data.msr_table[i], &clk_msr_fops);
 	}
 
-	return 0;
+	return devm_add_action_or_reset(&pdev->dev, meson_msr_debugfs_remove,
+					root);
 }
 
 static const struct msr_reg_offset msr_reg_offset = {
-- 
2.47.3



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-06-02  3:52 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-02  3:52 [PATCH] soc: amlogic: meson-clk-measure: fix debugfs directory leak on unbind Yi Ding

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox