summaryrefslogtreecommitdiff
path: root/drivers/thermal
diff options
context:
space:
mode:
authorThomas Sujith <sujith.thomas@intel.com>2008-02-15 08:58:50 +0300
committerLen Brown <len.brown@intel.com>2008-02-16 02:21:30 +0300
commitc751670902c3dd9abbed279170a832e6a1e6cf94 (patch)
tree784cf0161d60a3bd4c1b6a6d160c9657b717e83a /drivers/thermal
parent101142c37be8e5af9b847860219217e6b958c739 (diff)
downloadlinux-c751670902c3dd9abbed279170a832e6a1e6cf94.tar.xz
thermal: validate input parameters
Added sanity check to make sure that thermal zone and cooling device exists. Signed-off-by: Thomas Sujith <sujith.thomas@intel.com> Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/thermal')
-rw-r--r--drivers/thermal/thermal.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/drivers/thermal/thermal.c b/drivers/thermal/thermal.c
index e782b3e7fcdb..5f1d318f0574 100644
--- a/drivers/thermal/thermal.c
+++ b/drivers/thermal/thermal.c
@@ -306,12 +306,23 @@ int thermal_zone_bind_cooling_device(struct thermal_zone_device *tz,
{
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 =