summaryrefslogtreecommitdiffstats
path: root/drivers/thermal/thermal_sys.c
diff options
context:
space:
mode:
authorGuenter Roeck <linux@roeck-us.net>2012-07-21 10:53:48 +1000
committerZhang Rui <rui.zhang@intel.com>2012-09-24 14:44:37 +0800
commit79a49168b595f5400ed3108cd57e90f5bbe144ca (patch)
tree6f504185a9163695adfe87ae07dcc72694cb36c8 /drivers/thermal/thermal_sys.c
parentf4a821ce6ed41970d0155f55067fb07009974fbe (diff)
thermal: fix potential out-of-bounds memory access
temp_crit.name and temp_input.name have a length of 16 bytes. Using THERMAL_NAME_LENGTH (20) as length parameter for snprintf() may result in out-of-bounds memory accesses. Replace it with sizeof(). Addresses Coverity #115679 Signed-off-by: Guenter Roeck <linux@roeck-us.net> Cc: Len Brown <lenb@kernel.org> Cc: "Brown, Len" <len.brown@intel.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Diffstat (limited to 'drivers/thermal/thermal_sys.c')
-rw-r--r--drivers/thermal/thermal_sys.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/thermal/thermal_sys.c b/drivers/thermal/thermal_sys.c
index 5be8728c88a..36e6f4d4ec3 100644
--- a/drivers/thermal/thermal_sys.c
+++ b/drivers/thermal/thermal_sys.c
@@ -598,7 +598,7 @@ thermal_add_hwmon_sysfs(struct thermal_zone_device *tz)
temp->tz = tz;
hwmon->count++;
- snprintf(temp->temp_input.name, THERMAL_NAME_LENGTH,
+ snprintf(temp->temp_input.name, sizeof(temp->temp_input.name),
"temp%d_input", hwmon->count);
temp->temp_input.attr.attr.name = temp->temp_input.name;
temp->temp_input.attr.attr.mode = 0444;
@@ -611,7 +611,8 @@ thermal_add_hwmon_sysfs(struct thermal_zone_device *tz)
if (tz->ops->get_crit_temp) {
unsigned long temperature;
if (!tz->ops->get_crit_temp(tz, &temperature)) {
- snprintf(temp->temp_crit.name, THERMAL_NAME_LENGTH,
+ snprintf(temp->temp_crit.name,
+ sizeof(temp->temp_crit.name),
"temp%d_crit", hwmon->count);
temp->temp_crit.attr.attr.name = temp->temp_crit.name;
temp->temp_crit.attr.attr.mode = 0444;