linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] PM / devfreq: Unlock mutex and free devfreq struct in error path
@ 2021-03-15  9:31 ` Lukasz Luba
  2021-03-15  9:54   ` Chanwoo Choi
  0 siblings, 1 reply; 3+ messages in thread
From: Lukasz Luba @ 2021-03-15  9:31 UTC (permalink / raw)
  To: linux-kernel, linux-pm, cw00.choi
  Cc: lukasz.luba, myungjoo.ham, kyungmin.park, stable

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 --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) {
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] PM / devfreq: Unlock mutex and free devfreq struct in error path
  2021-03-15  9:31 ` [PATCH v2] PM / devfreq: Unlock mutex and free devfreq struct in error path Lukasz Luba
@ 2021-03-15  9:54   ` Chanwoo Choi
  2021-03-15 10:01     ` Lukasz Luba
  0 siblings, 1 reply; 3+ messages in thread
From: Chanwoo Choi @ 2021-03-15  9:54 UTC (permalink / raw)
  To: Lukasz Luba, linux-kernel, linux-pm; +Cc: myungjoo.ham, kyungmin.park, stable

On 3/15/21 6:31 PM, Lukasz Luba wrote:
> 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 --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) {
> 


Applied it. Thanks.

-- 
Best Regards,
Chanwoo Choi
Samsung Electronics

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] PM / devfreq: Unlock mutex and free devfreq struct in error path
  2021-03-15  9:54   ` Chanwoo Choi
@ 2021-03-15 10:01     ` Lukasz Luba
  0 siblings, 0 replies; 3+ messages in thread
From: Lukasz Luba @ 2021-03-15 10:01 UTC (permalink / raw)
  To: Chanwoo Choi; +Cc: linux-kernel, linux-pm, myungjoo.ham, kyungmin.park, stable



On 3/15/21 9:54 AM, Chanwoo Choi wrote:
> On 3/15/21 6:31 PM, Lukasz Luba wrote:
>> 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 --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) {
>>
> 
> 
> Applied it. Thanks.
> 

Thank you Chanwoo!

Regards,
Lukasz

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-03-15 10:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20210315093239epcas1p4516341a9f5614f59bfeb6af66e146540@epcas1p4.samsung.com>
2021-03-15  9:31 ` [PATCH v2] PM / devfreq: Unlock mutex and free devfreq struct in error path Lukasz Luba
2021-03-15  9:54   ` Chanwoo Choi
2021-03-15 10:01     ` Lukasz Luba

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).