counter: rz-mtu3-cnt: Balance runtime PM on enable failure
Subsystems (3)
PATCH 1/1 counter: rz-mtu3-cnt: Balance runtime PM on enable failure
rz_mtu3_count_enable_write() used pm_runtime_get_sync() without checking its return value before initializing a counter. A failed runtime resume was therefore ignored and the callback continued with the device unavailable.
Use pm_runtime_resume_and_get() and return a failed resume to the Counter core. Keep the matching put when shared-channel initialization fails after a successful resume, and leave the cached enable state unchanged.
This issue was found by a static analysis checker and confirmed by manual source review.
Fixes 0be8907359df ("counter: Add Renesas RZ/G2L MTU3a counter driver")
Signed-off-by Ruoyu Wang <[email protected]>
--- drivers/counter/rz-mtu3-cnt.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/counter/rz-mtu3-cnt.c +7 -2
@@ -504,9 +504,14 @@ 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 <0 ) + goto exit; + ret =rz_mtu3_initialize_counter (counter, count->id); -if (ret ==0 ) +if (ret) +pm_runtime_put (counter->parent); +else priv->count_is_enabled[count->id] = true; }else {rz_mtu3_terminate_counter (counter, count->id);
Signature · 1 line
2.51.0