From: "Rafael J. Wysocki" <rjw@rjwysocki.net>
To: Dirk Brandewie <dirk.brandewie@gmail.com>
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: Tue, 22 Oct 2013 01:06:02 +0200 [thread overview]
Message-ID: <7950903.3bCg8Tn2fH@vostro.rjw.lan> (raw)
In-Reply-To: <5265AE27.90600@gmail.com>
On Monday, October 21, 2013 03:43:51 PM Dirk Brandewie wrote:
> 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.
What was caught by the tool was the fact that 1UL << 32 might overflow on
32-bit, so using BIT(32) wasn't correct.
> I didn't see a downside to giving the compilier complete information.
Well, in that case the function's argument should be u64 rather than int.
Either you know that it won't overflow, in which case the explicit type
casting doesn't change anything, or you are not sure, in which case it's
better to use u64 as the original type anyway in my opinion.
Thanks!
--
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
next prev parent reply other threads:[~2013-10-21 22:54 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-20 3:31 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
2013-10-21 23:06 ` Rafael J. Wysocki [this message]
[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=7950903.3bCg8Tn2fH@vostro.rjw.lan \
--to=rjw@rjwysocki.net \
--cc=cpufreq@vger.kernel.org \
--cc=dirk.brandewie@gmail.com \
--cc=geyslan@gmail.com \
--cc=kernel-br@googlegroups.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--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
all inboxes | Powered by JetHome®