Skip to content

Commit 85b5212

Browse files
committed
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
2 parents ce07727 + 2a96243 commit 85b5212

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

drivers/thermal/intel/x86_pkg_temp_thermal.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,14 +124,16 @@ sys_set_trip_temp(struct thermal_zone_device *tzd, int trip, int temp)
124124
{
125125
struct zone_device *zonedev = thermal_zone_device_priv(tzd);
126126
u32 l, h, mask, shift, intr;
127-
int tj_max, ret;
127+
int tj_max, val, ret;
128128

129129
tj_max = intel_tcc_get_tjmax(zonedev->cpu);
130130
if (tj_max < 0)
131131
return tj_max;
132132
tj_max *= 1000;
133133

134-
if (trip >= MAX_NUMBER_OF_TRIPS || temp >= tj_max)
134+
val = (tj_max - temp)/1000;
135+
136+
if (trip >= MAX_NUMBER_OF_TRIPS || val < 0 || val > 0x7f)
135137
return -EINVAL;
136138

137139
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)
156158
if (!temp) {
157159
l &= ~intr;
158160
} else {
159-
l |= (tj_max - temp)/1000 << shift;
161+
l |= val << shift;
160162
l |= intr;
161163
}
162164

0 commit comments

Comments
 (0)