[PATCH 01/15] counter: rz-mtu3-cnt: put runtime PM on initialization error path

From: Cosmin Tanislav

Date: Mon Sep 14 2026 - 16:37:36 EST


If rz_mtu3_initialize_counter() fails, the runtime PM usage count is not
decremented.

rz_mtu3_initialize_counter() will fail if the requested channel is busy.

Call pm_runtime_put() in the error path to decrement the usage count,
and flip the check to keep the success path straightforward.

Cc: stable@xxxxxxxxxxxxxxx
Fixes: 0be8907359df ("counter: Add Renesas RZ/G2L MTU3a counter driver")
Signed-off-by: Cosmin Tanislav <cosmin-gabriel.tanislav.xa@xxxxxxxxxxx>
---
drivers/counter/rz-mtu3-cnt.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/counter/rz-mtu3-cnt.c b/drivers/counter/rz-mtu3-cnt.c
index 7bfb6979193c..48f183f0b54f 100644
--- a/drivers/counter/rz-mtu3-cnt.c
+++ b/drivers/counter/rz-mtu3-cnt.c
@@ -506,8 +506,12 @@ static int rz_mtu3_count_enable_write(struct counter_device *counter,
if (enable) {
pm_runtime_get_sync(counter->parent);
ret = rz_mtu3_initialize_counter(counter, count->id);
- if (ret == 0)
- priv->count_is_enabled[count->id] = true;
+ if (ret) {
+ pm_runtime_put(counter->parent);
+ goto exit;
+ }
+
+ priv->count_is_enabled[count->id] = true;
} else {
rz_mtu3_terminate_counter(counter, count->id);
priv->count_is_enabled[count->id] = false;
--
2.55.0