aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>2013-07-15 18:38:52 -0400
committerZhang Rui <rui.zhang@intel.com>2013-07-15 20:27:25 -0400
commit94e791f522595e2d5276e6d27a5b3b57f4e1cd8d (patch)
treed373b5c406fd2bbdbed68182caf91b13f00cc851
parentc7c1b3112e643d290471abd0f3b27ffeec6f28dd (diff)
Thermal: x86_pkg_temp: Limit number of pkg temp zones
Although it is unlikley that physical package id is set to some arbitary number, it is better to prevent in anycase. Since package temp zones use this in thermal zone type and for allocation, added a limit. Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
-rw-r--r--drivers/thermal/x86_pkg_temp_thermal.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/thermal/x86_pkg_temp_thermal.c b/drivers/thermal/x86_pkg_temp_thermal.c
index cf172d50b5d3..810143a6aa33 100644
--- a/drivers/thermal/x86_pkg_temp_thermal.c
+++ b/drivers/thermal/x86_pkg_temp_thermal.c
@@ -54,6 +54,8 @@ MODULE_PARM_DESC(notify_delay_ms,
54* is some wrong values returned by cpuid for number of thresholds. 54* is some wrong values returned by cpuid for number of thresholds.
55*/ 55*/
56#define MAX_NUMBER_OF_TRIPS 2 56#define MAX_NUMBER_OF_TRIPS 2
57/* Limit number of package temp zones */
58#define MAX_PKG_TEMP_ZONE_IDS 256
57 59
58struct phy_dev_entry { 60struct phy_dev_entry {
59 struct list_head list; 61 struct list_head list;
@@ -401,6 +403,9 @@ static int pkg_temp_thermal_device_add(unsigned int cpu)
401 if (!thres_count) 403 if (!thres_count)
402 return -ENODEV; 404 return -ENODEV;
403 405
406 if (topology_physical_package_id(cpu) > MAX_PKG_TEMP_ZONE_IDS)
407 return -ENODEV;
408
404 thres_count = clamp_val(thres_count, 0, MAX_NUMBER_OF_TRIPS); 409 thres_count = clamp_val(thres_count, 0, MAX_NUMBER_OF_TRIPS);
405 410
406 err = get_tj_max(cpu, &tj_max); 411 err = get_tj_max(cpu, &tj_max);