linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -next] PM / devfreq: Fix missing unlock on error in devfreq_add_device()
@ 2020-07-14  6:30 Wei Yongjun
  2020-07-14  9:37 ` Dan Carpenter
  0 siblings, 1 reply; 3+ messages in thread
From: Wei Yongjun @ 2020-07-14  6:30 UTC (permalink / raw)
  To: MyungJoo Ham, Kyungmin Park, Chanwoo Choi
  Cc: Wei Yongjun, linux-pm, kernel-janitors, Hulk Robot

Add the missing unlock before return from function devfreq_add_device()
in the error handling case.

Fixes: d7c46505a7ad ("PM / devfreq: Add support delayed timer for polling mode")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
---
 drivers/devfreq/devfreq.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
index 5320c3b37f35..2b54a59bb281 100644
--- a/drivers/devfreq/devfreq.c
+++ b/drivers/devfreq/devfreq.c
@@ -788,6 +788,7 @@ struct devfreq *devfreq_add_device(struct device *dev,
 
 	if (devfreq->profile->timer < 0
 		|| devfreq->profile->timer >= DEVFREQ_TIMER_NUM) {
+		mutex_unlock(&devfreq->lock);
 		goto err_out;
 	}




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

* Re: [PATCH -next] PM / devfreq: Fix missing unlock on error in devfreq_add_device()
  2020-07-14  6:30 [PATCH -next] PM / devfreq: Fix missing unlock on error in devfreq_add_device() Wei Yongjun
@ 2020-07-14  9:37 ` Dan Carpenter
  2020-07-14 10:59   ` Dan Carpenter
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2020-07-14  9:37 UTC (permalink / raw)
  To: Wei Yongjun
  Cc: MyungJoo Ham, Kyungmin Park, Chanwoo Choi, linux-pm,
	kernel-janitors, Hulk Robot

On Tue, Jul 14, 2020 at 06:30:25AM +0000, Wei Yongjun wrote:
> Add the missing unlock before return from function devfreq_add_device()
> in the error handling case.
> 
> Fixes: d7c46505a7ad ("PM / devfreq: Add support delayed timer for polling mode")
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
> ---
>  drivers/devfreq/devfreq.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
> index 5320c3b37f35..2b54a59bb281 100644
> --- a/drivers/devfreq/devfreq.c
> +++ b/drivers/devfreq/devfreq.c
> @@ -788,6 +788,7 @@ struct devfreq *devfreq_add_device(struct device *dev,
>  
>  	if (devfreq->profile->timer < 0
>  		|| devfreq->profile->timer >= DEVFREQ_TIMER_NUM) {
> +		mutex_unlock(&devfreq->lock);
>  		goto err_out;

This should be "goto err_dev;" and the unlock is not required because
we free "devfreq".

regards,
dan carpenter
>  	}
> 
> 

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

* Re: [PATCH -next] PM / devfreq: Fix missing unlock on error in devfreq_add_device()
  2020-07-14  9:37 ` Dan Carpenter
@ 2020-07-14 10:59   ` Dan Carpenter
  0 siblings, 0 replies; 3+ messages in thread
From: Dan Carpenter @ 2020-07-14 10:59 UTC (permalink / raw)
  To: Wei Yongjun
  Cc: MyungJoo Ham, Kyungmin Park, Chanwoo Choi, linux-pm,
	kernel-janitors, Hulk Robot

On Tue, Jul 14, 2020 at 12:37:58PM +0300, Dan Carpenter wrote:
> On Tue, Jul 14, 2020 at 06:30:25AM +0000, Wei Yongjun wrote:
> > Add the missing unlock before return from function devfreq_add_device()
> > in the error handling case.
> > 
> > Fixes: d7c46505a7ad ("PM / devfreq: Add support delayed timer for polling mode")
> > Reported-by: Hulk Robot <hulkci@huawei.com>
> > Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
> > ---
> >  drivers/devfreq/devfreq.c | 1 +
> >  1 file changed, 1 insertion(+)
> > 
> > diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
> > index 5320c3b37f35..2b54a59bb281 100644
> > --- a/drivers/devfreq/devfreq.c
> > +++ b/drivers/devfreq/devfreq.c
> > @@ -788,6 +788,7 @@ struct devfreq *devfreq_add_device(struct device *dev,
> >  
> >  	if (devfreq->profile->timer < 0
> >  		|| devfreq->profile->timer >= DEVFREQ_TIMER_NUM) {
> > +		mutex_unlock(&devfreq->lock);
> >  		goto err_out;
> 
> This should be "goto err_dev;" and the unlock is not required because
> we free "devfreq".

Also the error code needs to be set on this error path.

regards,
dan carpenter


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

end of thread, other threads:[~2020-07-14 10:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-07-14  6:30 [PATCH -next] PM / devfreq: Fix missing unlock on error in devfreq_add_device() Wei Yongjun
2020-07-14  9:37 ` Dan Carpenter
2020-07-14 10:59   ` Dan Carpenter

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).