diff options
author | Dan Carpenter <error27@gmail.com> | 2010-09-29 04:41:05 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2010-09-30 03:11:27 -0400 |
commit | b365a85c68161ea5db5476eb8845a91ceb1777ea (patch) | |
tree | 5fbda5fca7fecfa509e2955a220d08362441f2de | |
parent | 4193d9163582b05e33aca3392e46649e5c3da8d1 (diff) |
x86, UV: Use allocated buffer in tlb_uv.c:tunables_read()
The original code didn't check that the value returned from
snprintf() was less than the size of the buffer. Although it
didn't cause a runtime bug in this case, it makes the static
checkers complain.
Andrew Morton suggested a dynamically sized buffer would be
cleaner.
Suggested-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Dan Carpenter <error27@gmail.com>
Cc: Cliff Wickman <cpw@sgi.com>
Cc: Jack Steiner <steiner@sgi.com>
Cc: Robin Holt <holt@sgi.com>
LKML-Reference: <20100929083118.GA6376@bicker>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r-- | arch/x86/kernel/tlb_uv.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/arch/x86/kernel/tlb_uv.c b/arch/x86/kernel/tlb_uv.c index 312ef0292815..33e77e4f7c86 100644 --- a/arch/x86/kernel/tlb_uv.c +++ b/arch/x86/kernel/tlb_uv.c | |||
@@ -1001,10 +1001,10 @@ static int uv_ptc_seq_show(struct seq_file *file, void *data) | |||
1001 | static ssize_t tunables_read(struct file *file, char __user *userbuf, | 1001 | static ssize_t tunables_read(struct file *file, char __user *userbuf, |
1002 | size_t count, loff_t *ppos) | 1002 | size_t count, loff_t *ppos) |
1003 | { | 1003 | { |
1004 | char buf[300]; | 1004 | char *buf; |
1005 | int ret; | 1005 | int ret; |
1006 | 1006 | ||
1007 | ret = snprintf(buf, 300, "%s %s %s\n%d %d %d %d %d %d %d %d %d\n", | 1007 | buf = kasprintf(GFP_KERNEL, "%s %s %s\n%d %d %d %d %d %d %d %d %d\n", |
1008 | "max_bau_concurrent plugged_delay plugsb4reset", | 1008 | "max_bau_concurrent plugged_delay plugsb4reset", |
1009 | "timeoutsb4reset ipi_reset_limit complete_threshold", | 1009 | "timeoutsb4reset ipi_reset_limit complete_threshold", |
1010 | "congested_response_us congested_reps congested_period", | 1010 | "congested_response_us congested_reps congested_period", |
@@ -1012,7 +1012,12 @@ static ssize_t tunables_read(struct file *file, char __user *userbuf, | |||
1012 | timeoutsb4reset, ipi_reset_limit, complete_threshold, | 1012 | timeoutsb4reset, ipi_reset_limit, complete_threshold, |
1013 | congested_response_us, congested_reps, congested_period); | 1013 | congested_response_us, congested_reps, congested_period); |
1014 | 1014 | ||
1015 | return simple_read_from_buffer(userbuf, count, ppos, buf, ret); | 1015 | if (!buf) |
1016 | return -ENOMEM; | ||
1017 | |||
1018 | ret = simple_read_from_buffer(userbuf, count, ppos, buf, strlen(buf)); | ||
1019 | kfree(buf); | ||
1020 | return ret; | ||
1016 | } | 1021 | } |
1017 | 1022 | ||
1018 | /* | 1023 | /* |