Commit 0fe1329b authored by Dan Carpenter's avatar Dan Carpenter Committed by Rafael J. Wysocki

powercap/drivers/dtpm: Fix some missing unlock bugs

We need to unlock on these paths before returning.

Fixes: a20d0ef9 ("powercap/drivers/dtpm: Add API for dynamic thermal power management")
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Acked-by: default avatarDaniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent 2185c230
...@@ -147,13 +147,17 @@ static void __dtpm_add_power(struct dtpm *dtpm) ...@@ -147,13 +147,17 @@ static void __dtpm_add_power(struct dtpm *dtpm)
*/ */
int dtpm_update_power(struct dtpm *dtpm, u64 power_min, u64 power_max) int dtpm_update_power(struct dtpm *dtpm, u64 power_min, u64 power_max)
{ {
int ret = 0;
mutex_lock(&dtpm_lock); mutex_lock(&dtpm_lock);
if (power_min == dtpm->power_min && power_max == dtpm->power_max) if (power_min == dtpm->power_min && power_max == dtpm->power_max)
return 0; goto unlock;
if (power_max < power_min) if (power_max < power_min) {
return -EINVAL; ret = -EINVAL;
goto unlock;
}
__dtpm_sub_power(dtpm); __dtpm_sub_power(dtpm);
...@@ -164,9 +168,10 @@ int dtpm_update_power(struct dtpm *dtpm, u64 power_min, u64 power_max) ...@@ -164,9 +168,10 @@ int dtpm_update_power(struct dtpm *dtpm, u64 power_min, u64 power_max)
__dtpm_add_power(dtpm); __dtpm_add_power(dtpm);
unlock:
mutex_unlock(&dtpm_lock); mutex_unlock(&dtpm_lock);
return 0; return ret;
} }
/** /**
...@@ -187,8 +192,10 @@ int dtpm_release_zone(struct powercap_zone *pcz) ...@@ -187,8 +192,10 @@ int dtpm_release_zone(struct powercap_zone *pcz)
mutex_lock(&dtpm_lock); mutex_lock(&dtpm_lock);
if (!list_empty(&dtpm->children)) if (!list_empty(&dtpm->children)) {
mutex_unlock(&dtpm_lock);
return -EBUSY; return -EBUSY;
}
if (parent) if (parent)
list_del(&dtpm->sibling); list_del(&dtpm->sibling);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment