aboutsummaryrefslogtreecommitdiffstats
path: root/xen/drivers
diff options
context:
space:
mode:
authorTim Deegan <tim@xen.org>2013-09-12 12:29:21 +0100
committerTim Deegan <tim@xen.org>2013-09-12 17:47:08 +0100
commit2c40a7fa1cd5c693c424515c7c896e1a5a880bf5 (patch)
treee276bb1d45a9fcb0b7f75cddc58a3971b794b499 /xen/drivers
parentb5f9a29421d0d2587683e3a91f0659102e80a942 (diff)
downloadxen-2c40a7fa1cd5c693c424515c7c896e1a5a880bf5.tar.gz
xen-2c40a7fa1cd5c693c424515c7c896e1a5a880bf5.tar.bz2
xen-2c40a7fa1cd5c693c424515c7c896e1a5a880bf5.zip
cpufreq: avoid integer overflows.
The def_sampling_rate() one is, I think, a real bug. The others were spotted at the same time and are probably not bugs until we start dealing with 40GHz CPus. Coverity CID 1055682 Coverity CID 1055683 Signed-off-by: Tim Deegan <tim@xen.org> Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com> Acked-by: Jan Beulich <jbeulich@suse.com>
Diffstat (limited to 'xen/drivers')
-rw-r--r--xen/drivers/cpufreq/cpufreq_ondemand.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/xen/drivers/cpufreq/cpufreq_ondemand.c b/xen/drivers/cpufreq/cpufreq_ondemand.c
index b3f9ab89e6..7fdba03c23 100644
--- a/xen/drivers/cpufreq/cpufreq_ondemand.c
+++ b/xen/drivers/cpufreq/cpufreq_ondemand.c
@@ -144,7 +144,7 @@ static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info)
}
/* Check for frequency increase */
- if (max_load_freq > dbs_tuners_ins.up_threshold * policy->cur) {
+ if (max_load_freq > (uint64_t) dbs_tuners_ins.up_threshold * policy->cur) {
/* if we are already at full speed then break out early */
if (policy->cur == max)
return;
@@ -162,7 +162,8 @@ static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info)
* can support the current CPU usage without triggering the up
* policy. To be safe, we focus 10 points under the threshold.
*/
- if (max_load_freq < (dbs_tuners_ins.up_threshold - 10) * policy->cur) {
+ if (max_load_freq
+ < (uint64_t) (dbs_tuners_ins.up_threshold - 10) * policy->cur) {
uint64_t freq_next;
freq_next = max_load_freq / (dbs_tuners_ins.up_threshold - 10);
@@ -246,7 +247,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy, unsigned int event)
* is used for first time
*/
if ((dbs_enable == 1) && !dbs_tuners_ins.sampling_rate) {
- def_sampling_rate = policy->cpuinfo.transition_latency *
+ def_sampling_rate = (uint64_t) policy->cpuinfo.transition_latency *
DEF_SAMPLING_RATE_LATENCY_MULTIPLIER;
if (def_sampling_rate < MIN_STAT_SAMPLING_RATE)