summaryrefslogtreecommitdiffstats
path: root/drivers/thermal
diff options
context:
space:
mode:
authorEduardo Valentin2013-01-02 16:29:42 +0100
committerZhang Rui2013-01-17 08:09:22 +0100
commit6b2aa51d698492e8dc0a0ce6ce5b3193ccaec269 (patch)
tree2f34c327e3fb92f4851bb0c1dbcddea2db9670d8 /drivers/thermal
parentthermal: cleanup: use dev_* helper functions (diff)
downloadkernel-qcow2-linux-6b2aa51d698492e8dc0a0ce6ce5b3193ccaec269.tar.gz
kernel-qcow2-linux-6b2aa51d698492e8dc0a0ce6ce5b3193ccaec269.tar.xz
kernel-qcow2-linux-6b2aa51d698492e8dc0a0ce6ce5b3193ccaec269.zip
thermal: check for invalid trip setup when registering thermal device
This patch adds an extra check in the data structure while registering a thermal device. The check is to avoid registering zones with a number of trips greater than zero, but with no .get_trip_temp nor .get_trip_type callbacks. Receiving such data structure may end in wrong data access. Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com> Reviewed-by: Durgadoss R <durgadoss.r@intel.com> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Diffstat (limited to 'drivers/thermal')
-rw-r--r--drivers/thermal/thermal_sys.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/thermal/thermal_sys.c b/drivers/thermal/thermal_sys.c
index fba27c36d707..0a1bf6b032ea 100644
--- a/drivers/thermal/thermal_sys.c
+++ b/drivers/thermal/thermal_sys.c
@@ -1530,6 +1530,9 @@ struct thermal_zone_device *thermal_zone_device_register(const char *type,
if (!ops || !ops->get_temp)
return ERR_PTR(-EINVAL);
+ if (trips > 0 && !ops->get_trip_type)
+ return ERR_PTR(-EINVAL);
+
tz = kzalloc(sizeof(struct thermal_zone_device), GFP_KERNEL);
if (!tz)
return ERR_PTR(-ENOMEM);