public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dirk Brandewie <dirk.brandewie@gmail.com>
To: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: "Geyslan G. Bem" <geyslan@gmail.com>,
	kernel-br@googlegroups.com,
	Viresh Kumar <viresh.kumar@linaro.org>,
	"open list:CPU FREQUENCY DRI..." <cpufreq@vger.kernel.org>,
	"open list:CPU FREQUENCY DRI..." <linux-pm@vger.kernel.org>,
	open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] cpufreq: intel_pstate: fix possible integer overflow
Date: Mon, 21 Oct 2013 15:43:51 -0700	[thread overview]
Message-ID: <5265AE27.90600@gmail.com> (raw)
In-Reply-To: <1734089.XZ0ga7sQd1@vostro.rjw.lan>

On 10/21/2013 03:47 PM, Rafael J. Wysocki wrote:
> On Monday, October 21, 2013 08:56:22 AM Dirk Brandewie wrote:
>> On 10/19/2013 08:31 PM, Geyslan G. Bem wrote:
>>> The expression 'pstate << 8' is evaluated using 32-bit arithmetic while
>>> 'val' expects an expression of type u64.
>>>
>>> Signed-off-by: Geyslan G. Bem <geyslan@gmail.com>
>> Acked-by: Dirk Brandewie <dirk.j.brandewie@intel.com>
>
> Actually, isn't (pstate << 8) guaranteed not to overflow?
>

Yes, I was assuming this was caught by a static checking tool. I
didn't see a downside to giving the compilier complete information.

>>> ---
>>>    drivers/cpufreq/intel_pstate.c | 2 +-
>>>    1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
>>> index badf620..43446b5 100644
>>> --- a/drivers/cpufreq/intel_pstate.c
>>> +++ b/drivers/cpufreq/intel_pstate.c
>>> @@ -395,7 +395,7 @@ static void intel_pstate_set_pstate(struct cpudata *cpu, int pstate)
>>>    	trace_cpu_frequency(pstate * 100000, cpu->cpu);
>>>
>>>    	cpu->pstate.current_pstate = pstate;
>>> -	val = pstate << 8;
>>> +	val = (u64)pstate << 8;
>>>    	if (limits.no_turbo)
>>>    		val |= (u64)1 << 32;
>>>
>>>
>>


  reply	other threads:[~2013-10-21 22:43 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-20  3:31 [PATCH] cpufreq: intel_pstate: fix possible integer overflow Geyslan G. Bem
2013-10-21 15:56 ` Dirk Brandewie
2013-10-21 22:47   ` Rafael J. Wysocki
2013-10-21 22:43     ` Dirk Brandewie [this message]
2013-10-21 23:06       ` Rafael J. Wysocki
     [not found]         ` <CANOOhLRCC360exKKePsJGxYqx3ULZf1Ac0y16hsnPQNP69OHwA@mail.gmail.com>
2013-10-22 10:25           ` Geyslan Gregório Bem

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5265AE27.90600@gmail.com \
    --to=dirk.brandewie@gmail.com \
    --cc=cpufreq@vger.kernel.org \
    --cc=geyslan@gmail.com \
    --cc=kernel-br@googlegroups.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rjw@rjwysocki.net \
    --cc=viresh.kumar@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox