diff mbox series

[v2] PM / devfreq: Unlock mutex and free devfreq struct in error path

Message ID 20210315093123.20049-1-lukasz.luba@arm.com
State Accepted
Commit 8b50a7995770d41a2e8d9c422cd2882aca0dedd2
Headers show
Series [v2] PM / devfreq: Unlock mutex and free devfreq struct in error path | expand

Commit Message

Lukasz Luba March 15, 2021, 9:31 a.m. UTC
The devfreq->lock is held for time of setup. Release the lock in the
error path, before jumping to the end of the function.

Change the goto destination which frees the allocated memory.

Cc: v5.9+ <stable@vger.kernel.org> # v5.9+
Fixes: 4dc3bab8687f ("PM / devfreq: Add support delayed timer for polling mode")
Signed-off-by: Lukasz Luba <lukasz.luba@arm.com>
---
v2:
- added fixes tag and CC stable v5.9+
- used capital letter in commit header


 drivers/devfreq/devfreq.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
index b6d3e7db0b09..99b2eeedc238 100644
--- a/drivers/devfreq/devfreq.c
+++ b/drivers/devfreq/devfreq.c
@@ -822,7 +822,8 @@  struct devfreq *devfreq_add_device(struct device *dev,
 
 	if (devfreq->profile->timer < 0
 		|| devfreq->profile->timer >= DEVFREQ_TIMER_NUM) {
-		goto err_out;
+		mutex_unlock(&devfreq->lock);
+		goto err_dev;
 	}
 
 	if (!devfreq->profile->max_state && !devfreq->profile->freq_table) {