aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/acpi_power_meter.c
diff options
context:
space:
mode:
authorGuenter Roeck <linux@roeck-us.net>2012-06-21 09:21:05 -0400
committerGuenter Roeck <linux@roeck-us.net>2012-07-22 00:48:44 -0400
commit75311bea569d7ea77a5a3c5395bae27bb8a2df96 (patch)
tree2ce0cbffa47a9af6640a22f536d081a14d3a85f3 /drivers/hwmon/acpi_power_meter.c
parent27c4db3996ef0d27fb25e6991ebf6e507a920937 (diff)
hwmon: (acpi_power_meter) Fix unintentional integer overflow
Expression with two integer variables is calculated as integer before it is converted to u64. This may result in an integer overflow. Fix by declaring trip point variables as s64 instead of int. This patch addresses Coverity #200596: Unintentional integer overflow. Signed-off-by: Guenter Roeck <linux@roeck-us.net> Acked-by: Jean Delvare <khali@linux-fr.org>
Diffstat (limited to 'drivers/hwmon/acpi_power_meter.c')
-rw-r--r--drivers/hwmon/acpi_power_meter.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/drivers/hwmon/acpi_power_meter.c b/drivers/hwmon/acpi_power_meter.c
index 9a0821f1c914..5363da5f4d85 100644
--- a/drivers/hwmon/acpi_power_meter.c
+++ b/drivers/hwmon/acpi_power_meter.c
@@ -101,7 +101,7 @@ struct acpi_power_meter_resource {
101 unsigned long sensors_last_updated; 101 unsigned long sensors_last_updated;
102 struct sensor_device_attribute sensors[NUM_SENSORS]; 102 struct sensor_device_attribute sensors[NUM_SENSORS];
103 int num_sensors; 103 int num_sensors;
104 int trip[2]; 104 s64 trip[2];
105 int num_domain_devices; 105 int num_domain_devices;
106 struct acpi_device **domain_devices; 106 struct acpi_device **domain_devices;
107 struct kobject *holders_dir; 107 struct kobject *holders_dir;
@@ -308,8 +308,6 @@ static ssize_t set_trip(struct device *dev, struct device_attribute *devattr,
308 return res; 308 return res;
309 309
310 temp = DIV_ROUND_CLOSEST(temp, 1000); 310 temp = DIV_ROUND_CLOSEST(temp, 1000);
311 if (temp > INT_MAX)
312 return -EINVAL;
313 311
314 mutex_lock(&resource->lock); 312 mutex_lock(&resource->lock);
315 resource->trip[attr->index - 7] = temp; 313 resource->trip[attr->index - 7] = temp;