From: Yi Ding <yi.s.ding@gmail.com>
To: Neil Armstrong <neil.armstrong@linaro.org>,
Kevin Hilman <khilman@baylibre.com>
Cc: Jerome Brunet <jbrunet@baylibre.com>,
Martin Blumenstingl <martin.blumenstingl@googlemail.com>,
linux-arm-kernel@lists.infradead.org,
linux-amlogic@lists.infradead.org, linux-kernel@vger.kernel.org,
Yi Ding <yi.s.ding@gmail.com>
Subject: [PATCH] soc: amlogic: meson-clk-measure: fix debugfs directory leak on unbind
Date: Mon, 1 Jun 2026 20:52:09 -0700 [thread overview]
Message-ID: <20260602035209.62335-1-yi.s.ding@gmail.com> (raw)
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
reply other threads:[~2026-06-02 3:52 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260602035209.62335-1-yi.s.ding@gmail.com \
--to=yi.s.ding@gmail.com \
--cc=jbrunet@baylibre.com \
--cc=khilman@baylibre.com \
--cc=linux-amlogic@lists.infradead.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=martin.blumenstingl@googlemail.com \
--cc=neil.armstrong@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox