[PATCH 06/15] counter: rz-mtu3-cnt: disable channel before releasing
From: Cosmin Tanislav
Date: Mon Sep 14 2026 - 16:40:56 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>
---
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 d3daf258a3b8..e200a6548dfe 100644
--- a/drivers/counter/rz-mtu3-cnt.c
+++ b/drivers/counter/rz-mtu3-cnt.c
@@ -458,13 +458,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