[PATCH v2] counter: interrupt-cnt: use devm_mutex_init()
From: Stepan Ionichev
Date: Mon May 25 2026 - 11:12:50 EST
interrupt_cnt_probe() calls mutex_init() but neither this driver
nor the counter core issues a matching mutex_destroy() on unbind,
which leaks the lock debug state when CONFIG_DEBUG_MUTEXES is
enabled.
Switch to devm_mutex_init() so the mutex is torn down in the same
devm scope it was set up in.
Fixes: a55ebd47f21f ("counter: add IRQ or GPIO based counter")
Reviewed-by: Joshua Crofts <joshua.crofts1@xxxxxxxxx>
Signed-off-by: Stepan Ionichev <sozdayvek@xxxxxxxxx>
---
v2:
- Add Fixes tag and clarify the leak is only visible under
CONFIG_DEBUG_MUTEXES (William, Joshua)
- Add Reviewed-by from Joshua
v1: https://lore.kernel.org/all/20260523184418.7586-1-sozdayvek@xxxxxxxxx/
drivers/counter/interrupt-cnt.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/counter/interrupt-cnt.c b/drivers/counter/interrupt-cnt.c
index e6100b5fb..cd475382a 100644
--- a/drivers/counter/interrupt-cnt.c
+++ b/drivers/counter/interrupt-cnt.c
@@ -233,7 +233,9 @@ static int interrupt_cnt_probe(struct platform_device *pdev)
if (ret)
return ret;
- mutex_init(&priv->lock);
+ ret = devm_mutex_init(dev, &priv->lock);
+ if (ret)
+ return ret;
ret = devm_counter_add(dev, counter);
if (ret < 0)
--
2.43.0