lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <8a9b7bd0-9b21-1ce1-6176-cffff4b8d739@linaro.org>
Date:   Wed, 26 Jun 2019 12:19:53 +0200
From:   Daniel Lezcano <daniel.lezcano@...aro.org>
To:     "Rafael J. Wysocki" <rafael@...nel.org>,
        Viresh Kumar <viresh.kumar@...aro.org>
Cc:     "Rafael J. Wysocki" <rjw@...ysocki.net>,
        Eduardo Valentin <edubezval@...il.com>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        Sudeep Holla <sudeep.holla@....com>,
        Amit Daniel Kachhap <amit.kachhap@...il.com>,
        Javi Merino <javi.merino@...nel.org>,
        Zhang Rui <rui.zhang@...el.com>,
        Shawn Guo <shawnguo@...nel.org>,
        Sascha Hauer <s.hauer@...gutronix.de>,
        Pengutronix Kernel Team <kernel@...gutronix.de>,
        Fabio Estevam <festevam@...il.com>,
        NXP Linux Team <linux-imx@....com>,
        Keerthy <j-keerthy@...com>,
        "open list:CPU FREQUENCY DRIVERS - ARM BIG LITTLE" 
        <linux-pm@...r.kernel.org>,
        "moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE" 
        <linux-arm-kernel@...ts.infradead.org>,
        "open list:TI BANDGAP AND THERMAL DRIVER" 
        <linux-omap@...r.kernel.org>
Subject: Re: [PATCH V3 2/3] thermal/drivers/cpu_cooling: Unregister with the
 policy

On 26/06/2019 11:06, Rafael J. Wysocki wrote:
> On Wed, Jun 26, 2019 at 8:37 AM Viresh Kumar <viresh.kumar@...aro.org> wrote:
>>
>> On 26-06-19, 08:02, Daniel Lezcano wrote:
>>> On 26/06/2019 04:58, Viresh Kumar wrote:
>>>> On 25-06-19, 13:32, Daniel Lezcano wrote:
>>>>> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
>>>>> index aee024e42618..f07454249fbc 100644
>>>>> --- a/drivers/cpufreq/cpufreq.c
>>>>> +++ b/drivers/cpufreq/cpufreq.c
>>>>> @@ -1379,8 +1379,8 @@ static int cpufreq_online(unsigned int cpu)
>>>>>            cpufreq_driver->ready(policy);
>>>>>
>>>>>    if (cpufreq_thermal_control_enabled(cpufreq_driver))
>>>>> -          policy->cdev = of_cpufreq_cooling_register(policy);
>>>>> -
>>>>> +          of_cpufreq_cooling_register(policy);
>>>>> +
>>>>
>>>> We don't need any error checking here anymore ?
>>>
>>> There was no error checking initially. This comment and the others below
>>> are for an additional patch IMO, not a change in this one.
>>
>> right, but ...
>>
>>>>> -void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev)
>>>>> +void cpufreq_cooling_unregister(struct cpufreq_policy *policy)
>>>>>  {
>>>>>    struct cpufreq_cooling_device *cpufreq_cdev;
>>>>>    bool last;
>>>>>
>>>>> -  if (!cdev)
>>>>> -          return;
>>
>> we used to return without any errors from here. Now we will have
>> problems if regsitering fails for some reason.
> 
> Specifically, the last cpufreq_cdev in the list will be unregistered
> AFAICS, and without removing it from the list for that matter, which
> isn't what the caller wants.

Indeed,

What about the resulting code above:

void __cpufreq_cooling_unregister(struct cpufreq_cooling_device
*cpufreq_cdev, int last)
{
        /* Unregister the notifier for the last cpufreq cooling device */
        if (last)
                cpufreq_unregister_notifier(&thermal_cpufreq_notifier_block,
                                            CPUFREQ_POLICY_NOTIFIER);

        thermal_cooling_device_unregister(cpufreq_cdev->cdev);
        ida_simple_remove(&cpufreq_ida, cpufreq_cdev->id);
        kfree(cpufreq_cdev->idle_time);
        kfree(cpufreq_cdev);
}

/**

 * cpufreq_cooling_unregister - function to remove cpufreq cooling
device.
 * @cdev: thermal cooling device pointer.

 *

 * This interface function unregisters the "thermal-cpufreq-%x" cooling
device.
 */
void cpufreq_cooling_unregister(struct cpufreq_policy *policy)
{
        struct cpufreq_cooling_device *cpufreq_cdev;
        bool last;

        mutex_lock(&cooling_list_lock);
        list_for_each_entry(cpufreq_cdev, &cpufreq_cdev_list, node) {
                if (cpufreq_cdev->policy == policy) {
                        list_del(&cpufreq_cdev->node);
                        last = list_empty(&cpufreq_cdev_list);
                        break;
                }
        }
        mutex_unlock(&cooling_list_lock);

        if (cpufreq_cdev->policy == policy)
                __cpufreq_cooling_unregister(cpufreq_cdev, last);
}
EXPORT_SYMBOL_GPL(cpufreq_cooling_unregister);




-- 
 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ