RE: [PATCH] PM / devfreq: Add proper locking around list_del()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> Use devfreq_list_lock around list_del() to prevent list corruption.
> 
> Signed-off-by: Axel Lin <axel.lin@xxxxxxxxxx>
> ---
>  drivers/devfreq/devfreq.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
> index 478006b..70369b0 100644
> --- a/drivers/devfreq/devfreq.c
> +++ b/drivers/devfreq/devfreq.c
> @@ -604,7 +604,10 @@ struct devfreq *devfreq_add_device(struct device *dev,
>  	return devfreq;
>  
>  err_init:
> +	mutex_lock(&devfreq_list_lock);
>  	list_del(&devfreq->node);
> +	mutex_unlock(&devfreq_list_lock);
> +
>  	device_unregister(&devfreq->dev);
>  err_out:
>  	return ERR_PTR(err);

I'd rather modify:

-        mutex_unlock(&devfreq_list_lock);
         if (err) {
                 dev_err(dev, "%s: Unable to start governor for the device\n",
                         __func__);
                 goto err_init;
         }
+        mutex_unlock(&devfreq_list_lock);
 
         return devfreq;
 err_init:
         list_del(&devfreq->node);
         device_unregister(&devfreq->dev);
+        mutex_unlock(&devfreq_list_lock);
 
 
How do you think?


Cheers,
MyungJoo

[Index of Archives]     [Linux SoC Development]     [Linux Rockchip Development]     [Linux USB Development]     [Video for Linux]     [Linux Audio Users]     [Linux SCSI]     [Yosemite News]

  Powered by Linux