Skip to content

Commit

Permalink
thermal: validate input parameters
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Thomas Sujith authored and Len Brown committed Feb 15, 2008
1 parent 101142c commit c751670
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion drivers/thermal/thermal.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down

0 comments on commit c751670

Please sign in to comment.