diff mbox

[08/12] thermal: add sanity check for the passive attribute

Message ID 200911172227.nAHMRZX8023365@imap1.linux-foundation.org (mailing list archive)
State RFC, archived
Headers show

Commit Message

Andrew Morton Nov. 17, 2009, 10:27 p.m. UTC
None
diff mbox

Patch

diff -puN Documentation/thermal/sysfs-api.txt~thermal-add-sanity-check-for-the-passive-attribute Documentation/thermal/sysfs-api.txt
--- a/Documentation/thermal/sysfs-api.txt~thermal-add-sanity-check-for-the-passive-attribute
+++ a/Documentation/thermal/sysfs-api.txt
@@ -206,6 +206,7 @@  passive
 	passive trip point for the zone. Activation is done by polling with
 	an interval of 1 second.
 	Unit: millidegrees Celsius
+	Valid values: 0 (disabled) or greater than 1000
 	RW, Optional
 
 *****************************
diff -puN drivers/thermal/thermal_sys.c~thermal-add-sanity-check-for-the-passive-attribute drivers/thermal/thermal_sys.c
--- a/drivers/thermal/thermal_sys.c~thermal-add-sanity-check-for-the-passive-attribute
+++ a/drivers/thermal/thermal_sys.c
@@ -225,6 +225,12 @@  passive_store(struct device *dev, struct
 	if (!sscanf(buf, "%d\n", &state))
 		return -EINVAL;
 
+	/* sanity check: values below 1000 millicelcius don't make sense
+	 * and can cause the system to go into a thermal heart attack
+	 */
+	if (state && state < 1000)
+		return -EINVAL;
+
 	if (state && !tz->forced_passive) {
 		mutex_lock(&thermal_list_lock);
 		list_for_each_entry(cdev, &thermal_cdev_list, node) {