[-next] PM / devfreq: Fix missing unlock on error in devfreq_add_device()
diff mbox series

Message ID 20200714063025.118829-1-weiyongjun1@huawei.com
State New
Delegated to: Chanwoo Choi
Headers show
Series
  • [-next] PM / devfreq: Fix missing unlock on error in devfreq_add_device()
Related show

Commit Message

Wei Yongjun July 14, 2020, 6:30 a.m. UTC
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(+)

Comments

Dan Carpenter July 14, 2020, 9:37 a.m. UTC | #1
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
>  	}
> 
>
Dan Carpenter July 14, 2020, 10:59 a.m. UTC | #2
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

Patch
diff mbox series

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;
 	}