summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2023-03-27 13:47:11 +0200
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2023-03-27 13:47:11 +0200
commit85b52122e5426e15602c0b979012e50d7271ea1a (patch)
tree55948bcbc7d87f04fa6a4b9975a597289e0b04f6
parentce07727aff5bec20f29abe9263a51ed6a355b228 (diff)
parent2a96243e22f880ad53a977e09680aee276dc50b5 (diff)
downloadlinux-85b52122e5426e15602c0b979012e50d7271ea1a.tar.gz
linux-85b52122e5426e15602c0b979012e50d7271ea1a.tar.bz2
linux-85b52122e5426e15602c0b979012e50d7271ea1a.zip
Merge branch 'thermal-intel'
Merge an x86_pkg_temp_thermal Intel thermal driver fix (Zhang Rui). * thermal-intel: thermal: intel: x86_pkg_temp_thermal: Add lower bound check for sysfs input
-rw-r--r--drivers/thermal/intel/x86_pkg_temp_thermal.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/drivers/thermal/intel/x86_pkg_temp_thermal.c b/drivers/thermal/intel/x86_pkg_temp_thermal.c
index c4ec314441be..11a7f8108bbb 100644
--- a/drivers/thermal/intel/x86_pkg_temp_thermal.c
+++ b/drivers/thermal/intel/x86_pkg_temp_thermal.c
@@ -124,14 +124,16 @@ sys_set_trip_temp(struct thermal_zone_device *tzd, int trip, int temp)
{
struct zone_device *zonedev = thermal_zone_device_priv(tzd);
u32 l, h, mask, shift, intr;
- int tj_max, ret;
+ int tj_max, val, ret;
tj_max = intel_tcc_get_tjmax(zonedev->cpu);
if (tj_max < 0)
return tj_max;
tj_max *= 1000;
- if (trip >= MAX_NUMBER_OF_TRIPS || temp >= tj_max)
+ val = (tj_max - temp)/1000;
+
+ if (trip >= MAX_NUMBER_OF_TRIPS || val < 0 || val > 0x7f)
return -EINVAL;
ret = rdmsr_on_cpu(zonedev->cpu, MSR_IA32_PACKAGE_THERM_INTERRUPT,
@@ -156,7 +158,7 @@ sys_set_trip_temp(struct thermal_zone_device *tzd, int trip, int temp)
if (!temp) {
l &= ~intr;
} else {
- l |= (tj_max - temp)/1000 << shift;
+ l |= val << shift;
l |= intr;
}