Skip to contentSkip to conversation

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

PATCH Applied Lukasz Luba 2 participants 3 messages Mar 15, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 PM / devfreq: Unlock mutex and free devfreq struct in error path

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+ <[email protected]> # v5.9+
Fixes 4dc3bab8687f ("PM / devfreq: Add support delayed timer for polling mode")

---
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(-)
drivers/devfreq/devfreq.c +2 -1
index b6d3e7db0b09..99b2eeedc238 100644
@@ -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) {
Signature · 1 line
2.17.1
maintainer Applied
#1 lore raw
Quoted 23 lines · Lukasz Luba

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+ <[email protected]> # v5.9+
Fixes 4dc3bab8687f ("PM / devfreq: Add support delayed timer for polling mode")

---
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(-)
drivers/devfreq/devfreq.c +0 -0
index b6d3e7db0b09..99b2eeedc238 100644

drivers/devfreq/devfreq.c struct devfreq *devfreq_add_device(struct device *dev, · line 829

Quoted 9 lines
drivers/devfreq/devfreq.c +2 -1
@@ -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) {

Applied it. Thanks.

Signature · 3 lines
Best Regards,
Chanwoo Choi
Samsung Electronics
#2 lore raw
Quoted 31 lines · Chanwoo Choi
Quoted 30 lines · Lukasz Luba

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+ <[email protected]> # v5.9+
Fixes 4dc3bab8687f ("PM / devfreq: Add support delayed timer for polling mode")

---
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(-)
drivers/devfreq/devfreq.c +2 -1
index b6d3e7db0b09..99b2eeedc238 100644
@@ -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;
  	}
 
Quoted 6 lines

drivers/devfreq/devfreq.c struct devfreq *devfreq_add_device(struct device *dev, · line 829

Quoted 2 lines
drivers/devfreq/devfreq.c +0 -0
  	if (!devfreq->profile->max_state && !devfreq->profile->freq_table) {

Applied it. Thanks.

Thank you Chanwoo!

Regards,
Lukasz