Re: [PATCH v3] PM / devfreq: Fix devfreq_add_device() when drivers are built as modules.

From: Enric Balletbo i Serra
Date: Tue Jul 03 2018 - 09:16:44 EST


Hi MyungJoo

On 03/07/18 12:57, MyungJoo Ham wrote:
>> @@ -988,12 +1030,13 @@ static ssize_t governor_store(struct device *dev, struct device_attribute *attr,
>> if (ret != 1)
>> return -EINVAL;
>>
>> - mutex_lock(&devfreq_list_lock);
>> - governor = find_devfreq_governor(str_governor);
>> + governor = try_then_request_governor(str_governor);
>> if (IS_ERR(governor)) {
>> - ret = PTR_ERR(governor);
>> - goto out;
>> + return PTR_ERR(governor);
>> }
>> +
>> + mutex_lock(&devfreq_list_lock);
>> +
>> if (df->governor == governor) {
>> ret = 0;
>> goto out;
>> --
>
> The possibility that the result of try_then_request_governor is
> not kept protected until the line of
> "if (df->governor == governor)" is itching.
>
> Can you make it kept "locked" from the return of
> find_devfreq_governor() (either in try_then... or in this function)
> to the unlock of governor_store()?
>

Sure, I'll send v4 in a minute.

Thanks,
Enric

>
> Cheers,
> MyungJoo
>