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

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

 



On Thu, Sep 29, 2016 at 11:13 AM, Axel Lin <axel.lin@xxxxxxxxxx> wrote:
> Use devfreq_list_lock around list_del() to prevent list corruption.
>
> Signed-off-by: Axel Lin <axel.lin@xxxxxxxxxx>

LGTM.

Acked-by: MyungJoo Ham <myungjoo.ham@xxxxxxxxxxx>

> ---
> v2: changes base on MyungJoo's comment.
> Note, devfreq_list_lock lock region does not to include device_unregister(&devfreq->dev);
>  drivers/devfreq/devfreq.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
> index 478006b..66d3c718 100644
> --- a/drivers/devfreq/devfreq.c
> +++ b/drivers/devfreq/devfreq.c
> @@ -594,17 +594,19 @@ struct devfreq *devfreq_add_device(struct device *dev,
>         if (devfreq->governor)
>                 err = devfreq->governor->event_handler(devfreq,
>                                         DEVFREQ_GOV_START, NULL);
> -       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);
> +       mutex_unlock(&devfreq_list_lock);
> +
>         device_unregister(&devfreq->dev);
>  err_out:
>         return ERR_PTR(err);
> --
> 2.7.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



-- 
MyungJoo Ham, Ph.D.
Frontier CS Lab, S/W Center, Samsung Electronics
--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[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