From 39c8274ba2c8edd3743aceb7b4d9b048aab01108 Mon Sep 17 00:00:00 2001 From: Ioannis Karachalios Date: Sun, 10 Nov 2024 22:37:03 +0200 Subject: [PATCH] drivers: counter: Fix unbalanced policy state lock This commit should deal with fixing unbalanced policy state locks. When PM and PM_DEVICE are declared, default state, policy locks should be given only when active. Signed-off-by: Ioannis Karachalios --- drivers/counter/counter_smartbond_timer.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/counter/counter_smartbond_timer.c b/drivers/counter/counter_smartbond_timer.c index 8ee8f006dae6a..1869c3e6911e6 100644 --- a/drivers/counter/counter_smartbond_timer.c +++ b/drivers/counter/counter_smartbond_timer.c @@ -68,7 +68,9 @@ static void counter_smartbond_pm_policy_state_lock_get(const struct device *dev) static void counter_smartbond_pm_policy_state_lock_put(const struct device *dev) { pm_device_runtime_put(dev); - pm_policy_state_lock_put(PM_STATE_STANDBY, PM_ALL_SUBSTATES); + if (pm_policy_state_lock_is_active(PM_STATE_STANDBY, PM_ALL_SUBSTATES)) { + pm_policy_state_lock_put(PM_STATE_STANDBY, PM_ALL_SUBSTATES); + } } /*