public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [patch 1/6] Generic thermal management: validate input parameters
@ 2008-02-15  5:22 Thomas, Sujith
  2008-02-15  6:09 ` Len Brown
  0 siblings, 1 reply; 2+ messages in thread
From: Thomas, Sujith @ 2008-02-15  5:22 UTC (permalink / raw)
  To: Andrew Morton; +Cc: lenb, mingo, linux-acpi, linux-kernel, linux-pm, Zhang, Rui

[-- Attachment #1: Type: text/plain, Size: 1136 bytes --]

From: Thomas Sujith <sujith.thomas@intel.com>

Added sanity check to make sure that thermal zone
and cooling device exists.

Signed-off-by: Thomas Sujith <sujith.thomas@intel.com>
---

 drivers/thermal/thermal.c |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletion(-)

Index: linux-2.6.24/drivers/thermal/thermal.c
===================================================================
--- linux-2.6.24.orig/drivers/thermal/thermal.c
+++ linux-2.6.24/drivers/thermal/thermal.c
@@ -306,12 +306,23 @@ int thermal_zone_bind_cooling_device(str
 {
 	struct thermal_cooling_device_instance *dev;
 	struct thermal_cooling_device_instance *pos;
+	struct thermal_zone_device *pos1;
+	struct thermal_cooling_device *pos2;
 	int result;
 
 	if (trip >= tz->trips || (trip < 0 && trip !=
THERMAL_TRIPS_NONE))
 		return -EINVAL;
 
-	if (!tz || !cdev)
+	list_for_each_entry(pos1, &thermal_tz_list, node) {
+		if (pos1 == tz)
+			break;
+	}
+	list_for_each_entry(pos2, &thermal_cdev_list, node) {
+		if (pos2 == cdev)
+			break;
+	}
+
+	if (tz != pos1 || cdev != pos2)
 		return -EINVAL;
 
 	dev =

[-- Attachment #2: [patch 1 of 6] Thermal Management - validate input parameters --]
[-- Type: application/octet-stream, Size: 1095 bytes --]

From: Thomas Sujith <sujith.thomas@intel.com>

Added sanity check to make sure that thermal zone
and cooling device exists.

Signed-off-by: Thomas Sujith <sujith.thomas@intel.com>
---

 drivers/thermal/thermal.c |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletion(-)

Index: linux-2.6.24/drivers/thermal/thermal.c
===================================================================
--- linux-2.6.24.orig/drivers/thermal/thermal.c
+++ linux-2.6.24/drivers/thermal/thermal.c
@@ -306,12 +306,23 @@ int thermal_zone_bind_cooling_device(str
 {
 	struct thermal_cooling_device_instance *dev;
 	struct thermal_cooling_device_instance *pos;
+	struct thermal_zone_device *pos1;
+	struct thermal_cooling_device *pos2;
 	int result;
 
 	if (trip >= tz->trips || (trip < 0 && trip != THERMAL_TRIPS_NONE))
 		return -EINVAL;
 
-	if (!tz || !cdev)
+	list_for_each_entry(pos1, &thermal_tz_list, node) {
+		if (pos1 == tz)
+			break;
+	}
+	list_for_each_entry(pos2, &thermal_cdev_list, node) {
+		if (pos2 == cdev)
+			break;
+	}
+
+	if (tz != pos1 || cdev != pos2)
 		return -EINVAL;
 
 	dev =

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-02-15  6:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-15  5:22 [patch 1/6] Generic thermal management: validate input parameters Thomas, Sujith
2008-02-15  6:09 ` Len Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox