counter: interrupt-cnt: use devm_mutex_init()
Subsystems (3)
PATCH 1/1 counter: interrupt-cnt: use devm_mutex_init()
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.
--- drivers/counter/interrupt-cnt.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/counter/interrupt-cnt.c +3 -1
@@ -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 )
Signature · 1 line
2.43.0
Quoted 4 lines · Stepan Ionichev
interrupt_cnt_probe()callsmutex_init()but neither this driver nor the counter core issues a matchingmutex_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
Signature · 3 lines
Kind regards CJD
William Breathitt Gray
maintainerQuoted 8 lines · Stepan Ionichev
interrupt_cnt_probe()callsmutex_init()but neither this driver nor the counter core issues a matchingmutex_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 <[email protected]>
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
Quoted 8 lines · Stepan Ionichev
interrupt_cnt_probe()callsmutex_init()but neither this driver nor the counter core issues a matchingmutex_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,
Signature · 1 line
William Breathitt Gray <[email protected]>