[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <7950903.3bCg8Tn2fH@vostro.rjw.lan>
Date: Tue, 22 Oct 2013 01:06:02 +0200
From: "Rafael J. Wysocki" <rjw@...ysocki.net>
To: Dirk Brandewie <dirk.brandewie@...il.com>
Cc: "Geyslan G. Bem" <geyslan@...il.com>, kernel-br@...glegroups.com,
Viresh Kumar <viresh.kumar@...aro.org>,
"open list:CPU FREQUENCY DRI..." <cpufreq@...r.kernel.org>,
"open list:CPU FREQUENCY DRI..." <linux-pm@...r.kernel.org>,
open list <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] cpufreq: intel_pstate: fix possible integer overflow
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@...il.com>
> >> Acked-by: Dirk Brandewie <dirk.j.brandewie@...el.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.
--
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