提交 c7516709 编写于 作者: T Thomas Sujith 提交者: Len Brown

thermal: validate input parameters

Added sanity check to make sure that thermal zone
and cooling device exists.
Signed-off-by: NThomas Sujith <sujith.thomas@intel.com>
Signed-off-by: NLen Brown <len.brown@intel.com>
上级 101142c3
...@@ -306,12 +306,23 @@ int thermal_zone_bind_cooling_device(struct thermal_zone_device *tz, ...@@ -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 *dev;
struct thermal_cooling_device_instance *pos; struct thermal_cooling_device_instance *pos;
struct thermal_zone_device *pos1;
struct thermal_cooling_device *pos2;
int result; int result;
if (trip >= tz->trips || (trip < 0 && trip != THERMAL_TRIPS_NONE)) if (trip >= tz->trips || (trip < 0 && trip != THERMAL_TRIPS_NONE))
return -EINVAL; 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; return -EINVAL;
dev = dev =
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册