public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] PM / devfreq: unlock mutex and free devfreq struct in error path
@ 2021-03-12 18:45 ` Lukasz Luba
  2021-03-15  7:20   ` Chanwoo Choi
  0 siblings, 1 reply; 3+ messages in thread
From: Lukasz Luba @ 2021-03-12 18:45 UTC (permalink / raw)
  To: linux-kernel, linux-pm, cw00.choi
  Cc: lukasz.luba, myungjoo.ham, kyungmin.park

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.

Signed-off-by: Lukasz Luba <lukasz.luba@arm.com>
---
 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] PM / devfreq: unlock mutex and free devfreq struct in error path
  2021-03-12 18:45 ` [PATCH] PM / devfreq: unlock mutex and free devfreq struct in error path Lukasz Luba
@ 2021-03-15  7:20   ` Chanwoo Choi
  2021-03-15  9:22     ` Lukasz Luba
  0 siblings, 1 reply; 3+ messages in thread
From: Chanwoo Choi @ 2021-03-15  7:20 UTC (permalink / raw)
  To: Lukasz Luba, linux-kernel, linux-pm; +Cc: myungjoo.ham, kyungmin.park

Hi Lukasz,

On 3/13/21 3:45 AM, 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.
> 
> Signed-off-by: Lukasz Luba <lukasz.luba@arm.com>
> ---
>  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) {
> 

Looks good to me. But, need to add the following information
and please use capital letter of the first character of patch title. Thanks.

Fixes: 4dc3bab8687f ("PM / devfreq: Add support delayed timer for polling mode")

Also, need to send it to stable lkml.

-- 
Best Regards,
Chanwoo Choi
Samsung Electronics

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

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

Hi Chanwoo,

On 3/15/21 7:20 AM, Chanwoo Choi wrote:
> Hi Lukasz,
> 
> On 3/13/21 3:45 AM, 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.
>>
>> Signed-off-by: Lukasz Luba <lukasz.luba@arm.com>
>> ---
>>   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) {
>>
> 
> Looks good to me. But, need to add the following information
> and please use capital letter of the first character of patch title. Thanks.

thanks for looking at this, sure, I'll use the capital letter.

> 
> Fixes: 4dc3bab8687f ("PM / devfreq: Add support delayed timer for polling mode")
> 
> Also, need to send it to stable lkml.
> 

I'll add the 'Fixes' tag and send v2 also into stable v5.8+:

Cc: v5.8+ <stable@vger.kernel.org> # v5.8+

Regards,
Lukasz

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

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

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <CGME20210312184551epcas1p2fe579b2a736cac2814b8a236869c4c27@epcas1p2.samsung.com>
2021-03-12 18:45 ` [PATCH] PM / devfreq: unlock mutex and free devfreq struct in error path Lukasz Luba
2021-03-15  7:20   ` Chanwoo Choi
2021-03-15  9:22     ` Lukasz Luba

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox