[PATCH v2 06/15] counter: rz-mtu3-cnt: disable channel before releasing
From: Cosmin Tanislav
Date: Sun Oct 04 2026 - 13:55:22 EST
Releasing a channel marks it as not busy, allowing other threads to
claim it. With the current logic, it is possible for another thread to
claim the channel before disable is called, since we release the channel
before we disable it, causing the channel to possibly remain disabled
while it should have been enabled.
Disable the channel before releasing it.
Fixes: 0be8907359df ("counter: Add Renesas RZ/G2L MTU3a counter driver")
Signed-off-by: Cosmin Tanislav <cosmin-gabriel.tanislav.xa@xxxxxxxxxxx>
---
V2:
* no changes
drivers/counter/rz-mtu3-cnt.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/counter/rz-mtu3-cnt.c b/drivers/counter/rz-mtu3-cnt.c
index 3e1323d40dbb..f3c4d857674f 100644
--- a/drivers/counter/rz-mtu3-cnt.c
+++ b/drivers/counter/rz-mtu3-cnt.c
@@ -456,13 +456,13 @@ static void rz_mtu3_terminate_counter(struct counter_device *counter, int id)
struct rz_mtu3_channel *const ch2 = rz_mtu3_get_ch(counter, 1);
if (id == RZ_MTU3_32_BIT_CH) {
- rz_mtu3_release_channel(ch2);
- rz_mtu3_release_channel(ch1);
rz_mtu3_disable(ch2);
rz_mtu3_disable(ch1);
+ rz_mtu3_release_channel(ch2);
+ rz_mtu3_release_channel(ch1);
} else {
- rz_mtu3_release_channel(ch);
rz_mtu3_disable(ch);
+ rz_mtu3_release_channel(ch);
}
}
--
2.55.0