Skip to content

Commit

Permalink
Thermal: x86_pkg_temp: Limit number of pkg temp zones
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Srinivas Pandruvada authored and Zhang Rui committed Jul 16, 2013
1 parent c7c1b31 commit 94e791f
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions drivers/thermal/x86_pkg_temp_thermal.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ MODULE_PARM_DESC(notify_delay_ms,
* is some wrong values returned by cpuid for number of thresholds.
*/
#define MAX_NUMBER_OF_TRIPS 2
/* Limit number of package temp zones */
#define MAX_PKG_TEMP_ZONE_IDS 256

struct phy_dev_entry {
struct list_head list;
Expand Down Expand Up @@ -401,6 +403,9 @@ static int pkg_temp_thermal_device_add(unsigned int cpu)
if (!thres_count)
return -ENODEV;

if (topology_physical_package_id(cpu) > MAX_PKG_TEMP_ZONE_IDS)
return -ENODEV;

thres_count = clamp_val(thres_count, 0, MAX_NUMBER_OF_TRIPS);

err = get_tj_max(cpu, &tj_max);
Expand Down

0 comments on commit 94e791f

Please sign in to comment.