From: Wentao Liang <vulab@iscas.ac.cn>
To: biju.das.jz@bp.renesas.com
Cc: lee@kernel.org, linux-iio@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org,
wbg@kernel.org, Wentao Liang <vulab@iscas.ac.cn>,
stable@vger.kernel.org
Subject: [PATCH] counter: rz-mtu3-cnt: Fix runtime PM leak in rz_mtu3_count_enable_write()
Date: Wed, 16 Sep 2026 09:22:42 +0000 [thread overview]
Message-ID: <20260916092242.2001358-1-vulab@iscas.ac.cn> (raw)
When enabling a counter, the runtime PM reference taken by
pm_runtime_get_sync() is never dropped if rz_mtu3_initialize_counter()
fails and returns an error, e.g. -EBUSY when the channel is already
requested. Because priv->count_is_enabled[] is left false, a subsequent
disable write also takes the early exit path, so the reference is never
recovered. Additionally, if pm_runtime_get_sync() itself fails the
device usage count is left incremented while the hardware is still
accessed with runtime PM suspended.
Use pm_runtime_resume_and_get() to resume the device and bail out if it
fails, and drop the runtime PM reference when
rz_mtu3_initialize_counter() fails.
Fixes: 0be8907359df ("counter: Add Renesas RZ/G2L MTU3a counter driver")
Cc: stable@vger.kernel.org
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
drivers/counter/rz-mtu3-cnt.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/counter/rz-mtu3-cnt.c b/drivers/counter/rz-mtu3-cnt.c
index 7bfb6979193c..2bfc92bea757 100644
--- a/drivers/counter/rz-mtu3-cnt.c
+++ b/drivers/counter/rz-mtu3-cnt.c
@@ -504,10 +504,15 @@ static int rz_mtu3_count_enable_write(struct counter_device *counter,
goto exit;
if (enable) {
- pm_runtime_get_sync(counter->parent);
+ ret = pm_runtime_resume_and_get(counter->parent);
+ if (ret)
+ goto exit;
+
ret = rz_mtu3_initialize_counter(counter, count->id);
if (ret == 0)
priv->count_is_enabled[count->id] = true;
+ else
+ pm_runtime_put(counter->parent);
} else {
rz_mtu3_terminate_counter(counter, count->id);
priv->count_is_enabled[count->id] = false;
--
2.34.1
next reply other threads:[~2026-09-16 9:23 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-16 9:22 Wentao Liang [this message]
2026-09-16 17:38 ` [PATCH] counter: rz-mtu3-cnt: Fix runtime PM leak in rz_mtu3_count_enable_write() William Breathitt Gray
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=20260916092242.2001358-1-vulab@iscas.ac.cn \
--to=vulab@iscas.ac.cn \
--cc=biju.das.jz@bp.renesas.com \
--cc=lee@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=stable@vger.kernel.org \
--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