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] [day] [month] [year] [list]
Message-ID: <CAMuHMdV7p93j_nbyOtjKo8na02C8YYcL4DcqjY2TP=9x_se+4w@mail.gmail.com>
Date:	Mon, 21 Apr 2014 10:01:13 +0200
From:	Geert Uytterhoeven <geert@...ux-m68k.org>
To:	Viresh Kumar <viresh.kumar@...aro.org>
Cc:	Geert Uytterhoeven <geert+renesas@...der.be>,
	Mike Turquette <mike.turquette@...aro.org>,
	"Rafael J. Wysocki" <rjw@...ysocki.net>,
	"cpufreq@...r.kernel.org" <cpufreq@...r.kernel.org>,
	"linux-pm@...r.kernel.org" <linux-pm@...r.kernel.org>,
	"linuxppc-dev@...ts.ozlabs.org" <linuxppc-dev@...ts.ozlabs.org>,
	Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 3/3] cpufreq: ppc: Fix handling of non-existent clocks

Hi Viresh,

On Mon, Apr 21, 2014 at 8:01 AM, Viresh Kumar <viresh.kumar@...aro.org> wrote:
> On 17 April 2014 15:23, Geert Uytterhoeven <geert+renesas@...der.be> wrote:
>> If the clock doesn't exist, clk_get_rate() returns -EINVAL
>
> You clk_get_rate() isn't written well then, it should return zero.

You're right, thanks!
Once again I looked at the wrong clk_get_rate() implementation :-(
These non-CCF variants should die soon...

So the original code was correct: if the clock is not valid, freq == 0,
and thus "freq < min_cpufreq" is true.

> @Mike: I didn't see this clearly mentioned in clk.h, should we fix
> that?
>
>>, which becomes
>> a large number (freq is u32), failing the "freq < min_cpufreq" test.
>> Explicitly test for "(u32)-EINVAL" to fix this.
>
> That's a bad check. We should have done this instead:
>
> (s32)freq < 0; but that would be true for high values of clock. And that's
> why clk_get_rate() must return zero for errors.
>
>> Update the comment, and fix a grammer issue while we're at it.
>>
>> Signed-off-by: Geert Uytterhoeven <geert+renesas@...der.be>
>> ---
>>  drivers/cpufreq/ppc-corenet-cpufreq.c |    7 ++++---
>>  1 file changed, 4 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/cpufreq/ppc-corenet-cpufreq.c b/drivers/cpufreq/ppc-corenet-cpufreq.c
>> index 53881d78a931..7027eab814ce 100644
>> --- a/drivers/cpufreq/ppc-corenet-cpufreq.c
>> +++ b/drivers/cpufreq/ppc-corenet-cpufreq.c
>> @@ -179,10 +179,11 @@ static int corenet_cpufreq_cpu_init(struct cpufreq_policy *policy)
>>                 clk = of_clk_get(data->parent, i);
>>                 freq = clk_get_rate(clk);
>>                 /*
>> -                * the clock is valid if its frequency is not masked
>> -                * and large than minimum allowed frequency.
>> +                * the clock is valid if it exists, its frequency is not
>> +                * masked, and larger than minimum allowed frequency.
>>                  */
>> -               if (freq < min_cpufreq || (mask & (1 << i)))
>> +               if (freq == (u32)-EINVAL || freq < min_cpufreq ||
>> +                   (mask & (1 << i)))
>>                         table[i].frequency = CPUFREQ_ENTRY_INVALID;
>>                 else
>>                         table[i].frequency = freq / 1000;

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@...ux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ