aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/fam15h_power.c
diff options
context:
space:
mode:
authorGuenter Roeck <linux@roeck-us.net>2012-06-21 09:26:12 -0400
committerGuenter Roeck <linux@roeck-us.net>2012-07-22 00:48:28 -0400
commit62867d491a27affee36194d4856564f2f4e12b3c (patch)
treec6befa5f0b75a14e1c36b932a433b05087f2a413 /drivers/hwmon/fam15h_power.c
parent58c3667d83376c2f3016465f59f22c19c8f846e1 (diff)
hwmon: (fam15h_power) Fix unintentional integer overflow
Expression with two unsigned integer variables is calculated as unsigned integer before it is converted to u64. This may result in an integer overflow. Fix by typecasting the left operand to u64 before performing the left shift. This patch addresses Coverity #402320: Unintentional integer overflow. Signed-off-by: Guenter Roeck <linux@roeck-us.net> Acked-by: Jean Delvare <khali@linux-fr.org> Acked-by: Andreas Herrmann <andreas.herrmann3@amd.com>
Diffstat (limited to 'drivers/hwmon/fam15h_power.c')
-rw-r--r--drivers/hwmon/fam15h_power.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/hwmon/fam15h_power.c b/drivers/hwmon/fam15h_power.c
index 6b13f1a4dc27..2764b78a784b 100644
--- a/drivers/hwmon/fam15h_power.c
+++ b/drivers/hwmon/fam15h_power.c
@@ -67,7 +67,8 @@ static ssize_t show_power(struct device *dev,
67 REG_TDP_LIMIT3, &val); 67 REG_TDP_LIMIT3, &val);
68 68
69 tdp_limit = val >> 16; 69 tdp_limit = val >> 16;
70 curr_pwr_watts = (tdp_limit + data->base_tdp) << running_avg_range; 70 curr_pwr_watts = ((u64)(tdp_limit +
71 data->base_tdp)) << running_avg_range;
71 curr_pwr_watts -= running_avg_capture; 72 curr_pwr_watts -= running_avg_capture;
72 curr_pwr_watts *= data->tdp_to_watts; 73 curr_pwr_watts *= data->tdp_to_watts;
73 74