* [PATCH] counter: interrupt-cnt: use devm_mutex_init()
@ 2026-05-23 18:44 Stepan Ionichev
2026-05-23 20:54 ` Joshua Crofts
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Stepan Ionichev @ 2026-05-23 18:44 UTC (permalink / raw)
To: wbg; +Cc: o.rempel, kernel, linux-iio, linux-kernel, andy, sozdayvek
interrupt_cnt_probe() calls mutex_init() but neither this driver
nor the counter core issues a matching mutex_destroy() on unbind,
so the lock debug state is leaked.
Switch to devm_mutex_init() so the mutex is torn down in the same
devm scope it was set up in.
Signed-off-by: Stepan Ionichev <sozdayvek@gmail.com>
---
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
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] counter: interrupt-cnt: use devm_mutex_init()
2026-05-23 18:44 [PATCH] counter: interrupt-cnt: use devm_mutex_init() Stepan Ionichev
@ 2026-05-23 20:54 ` Joshua Crofts
2026-05-23 22:51 ` William Breathitt Gray
2026-05-31 22:34 ` William Breathitt Gray
2 siblings, 0 replies; 4+ messages in thread
From: Joshua Crofts @ 2026-05-23 20:54 UTC (permalink / raw)
To: Stepan Ionichev; +Cc: wbg, o.rempel, kernel, linux-iio, linux-kernel, andy
On Sat, 23 May 2026 at 20:44, Stepan Ionichev <sozdayvek@gmail.com> wrote:
>
> interrupt_cnt_probe() calls mutex_init() but neither this driver
> nor the counter core issues a matching mutex_destroy() on unbind,
> so the lock debug state is leaked.
A little bit of a misconception, however unless you compile the kernel
with CONFIG_DEBUG_MUTEXES enabled, mutex_destroy() will translate
into a nop, so there won't be any leaks. Nevertheless, the devm_
counterpart makes debugging easier, therefore
Reviewed-by: Joshua Crofts <joshua.crofts1@gmail.com>
--
Kind regards
CJD
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] counter: interrupt-cnt: use devm_mutex_init()
2026-05-23 18:44 [PATCH] counter: interrupt-cnt: use devm_mutex_init() Stepan Ionichev
2026-05-23 20:54 ` Joshua Crofts
@ 2026-05-23 22:51 ` William Breathitt Gray
2026-05-31 22:34 ` William Breathitt Gray
2 siblings, 0 replies; 4+ messages in thread
From: William Breathitt Gray @ 2026-05-23 22:51 UTC (permalink / raw)
To: Stepan Ionichev
Cc: William Breathitt Gray, o.rempel, kernel, linux-iio,
linux-kernel, andy, joshua.crofts1
On Sat, May 23, 2026 at 11:44:18PM +0500, Stepan Ionichev wrote:
> interrupt_cnt_probe() calls mutex_init() but neither this driver
> nor the counter core issues a matching mutex_destroy() on unbind,
> so the lock debug state is leaked.
>
> Switch to devm_mutex_init() so the mutex is torn down in the same
> devm scope it was set up in.
>
> Signed-off-by: Stepan Ionichev <sozdayvek@gmail.com>
This sounds like a bug fix (albeit applicable only under
CONFIG_DEBUG_MUTEXES) so we should have a Fixes tag here, correct?
If this issue applies to counter-core and counter-chrdev, would you
submit patches for them as well?
William Breathitt Gray
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] counter: interrupt-cnt: use devm_mutex_init()
2026-05-23 18:44 [PATCH] counter: interrupt-cnt: use devm_mutex_init() Stepan Ionichev
2026-05-23 20:54 ` Joshua Crofts
2026-05-23 22:51 ` William Breathitt Gray
@ 2026-05-31 22:34 ` William Breathitt Gray
2 siblings, 0 replies; 4+ messages in thread
From: William Breathitt Gray @ 2026-05-31 22:34 UTC (permalink / raw)
To: Stepan Ionichev
Cc: William Breathitt Gray, o.rempel, kernel, linux-iio, linux-kernel, andy
On Sat, 23 May 2026 23:44:18 +0500, Stepan Ionichev wrote:
> interrupt_cnt_probe() calls mutex_init() but neither this driver
> nor the counter core issues a matching mutex_destroy() on unbind,
> so the lock debug state is leaked.
>
> Switch to devm_mutex_init() so the mutex is torn down in the same
> devm scope it was set up in.
>
> [...]
Applied, thanks!
[1/1] counter: interrupt-cnt: use devm_mutex_init()
commit: 4d9a902be374aea023f2193f729c26612e56b542
Best regards,
--
William Breathitt Gray <wbg@kernel.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-05-31 22:35 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-05-23 18:44 [PATCH] counter: interrupt-cnt: use devm_mutex_init() Stepan Ionichev
2026-05-23 20:54 ` Joshua Crofts
2026-05-23 22:51 ` William Breathitt Gray
2026-05-31 22:34 ` William Breathitt Gray
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®