From: Srinivas Pandruvada Date: Mon, 15 Jul 2013 22:38:52 +0000 (-0700) Subject: Thermal: x86_pkg_temp: Limit number of pkg temp zones X-Git-Tag: android-x86-4.4-r2~2894^2~1 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=94e791f522595e2d5276e6d27a5b3b57f4e1cd8d;p=android-x86%2Fkernel.git 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 Signed-off-by: Zhang Rui --- 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, * 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; @@ -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);