summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorCesar Eduardo Barros <cesarb@cesarb.net>2008-02-16 08:41:25 -0200
committerDave Jones <davej@redhat.com>2008-04-28 15:05:44 -0400
commit25aca347d49ffc38aa3b7e63ce9b90df7f8b79c8 (patch)
tree01ae9962d03db4ae07f808428600b5d3c725b607 /drivers
parent74212ca432982903d0fc6a0f282b199e000ad8b1 (diff)
downloadlinux-stable-25aca347d49ffc38aa3b7e63ce9b90df7f8b79c8.tar.gz
linux-stable-25aca347d49ffc38aa3b7e63ce9b90df7f8b79c8.tar.bz2
linux-stable-25aca347d49ffc38aa3b7e63ce9b90df7f8b79c8.zip
[CPUFREQ] fix show_trans_table
Fix show_trans_table when it overflows PAGE_SIZE. * Not all snprintf calls were protected against being passed a negative length. * When show_trans_table overflows, len might be > PAGE_SIZE. In that case, returns PAGE_SIZE. Signed-off-by: Cesar Eduardo Barros <cesarb@cesarb.net> Signed-off-by: Dave Jones <davej@codemonkey.org.uk>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/cpufreq/cpufreq_stats.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
index 070421a5480e..ef09e069433b 100644
--- a/drivers/cpufreq/cpufreq_stats.c
+++ b/drivers/cpufreq/cpufreq_stats.c
@@ -114,7 +114,7 @@ show_trans_table(struct cpufreq_policy *policy, char *buf)
stat->freq_table[i]);
}
if (len >= PAGE_SIZE)
- return len;
+ return PAGE_SIZE;
len += snprintf(buf + len, PAGE_SIZE - len, "\n");
@@ -131,8 +131,12 @@ show_trans_table(struct cpufreq_policy *policy, char *buf)
len += snprintf(buf + len, PAGE_SIZE - len, "%9u ",
stat->trans_table[i*stat->max_state+j]);
}
+ if (len >= PAGE_SIZE)
+ break;
len += snprintf(buf + len, PAGE_SIZE - len, "\n");
}
+ if (len >= PAGE_SIZE)
+ return PAGE_SIZE;
return len;
}
CPUFREQ_STATDEVICE_ATTR(trans_table,0444,show_trans_table);