From: Stepan Ionichev <sozdayvek@gmail.com>
To: wbg@kernel.org
Cc: o.rempel@pengutronix.de, kernel@pengutronix.de,
joshua.crofts1@gmail.com, linux-iio@vger.kernel.org,
linux-kernel@vger.kernel.org, andy@kernel.org,
sozdayvek@gmail.com
Subject: [PATCH v2] counter: interrupt-cnt: use devm_mutex_init()
Date: Mon, 25 May 2026 20:11:52 +0500 [thread overview]
Message-ID: <20260525151152.7238-1-sozdayvek@gmail.com> (raw)
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@gmail.com>
Signed-off-by: Stepan Ionichev <sozdayvek@gmail.com>
---
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@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
next reply other threads:[~2026-05-25 15:12 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-25 15:11 Stepan Ionichev [this message]
2026-05-27 6:56 ` William Breathitt Gray
2026-05-27 16:55 ` Jonathan Cameron
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=20260525151152.7238-1-sozdayvek@gmail.com \
--to=sozdayvek@gmail.com \
--cc=andy@kernel.org \
--cc=joshua.crofts1@gmail.com \
--cc=kernel@pengutronix.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=o.rempel@pengutronix.de \
--cc=wbg@kernel.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
all inboxes | Powered by JetHome®