diff options
author | Dan Carpenter <error27@gmail.com> | 2010-08-12 03:50:09 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-10-22 13:19:58 -0400 |
commit | a95898114059e1038f3f7ee9bd2e43aefa62709a (patch) | |
tree | a1d559d638fdfe2ee668628827c5a75927362ac8 /drivers/serial | |
parent | de838a93cbf35671f890360b886a5c2a8a5d1aa4 (diff) |
serial: mfd: snprintf() returns largish values
snprintf() returns the number of bytes which would have been written so
it can be larger than the size of the buffer. In this case it's fine,
but people copy and paste this code so I've fixed it.
Signed-off-by: Dan Carpenter <error27@gmail.com>
Acked-by: Feng Tang <feng.tang@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/serial')
-rw-r--r-- | drivers/serial/mfd.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/drivers/serial/mfd.c b/drivers/serial/mfd.c index 5dff45c76d32..ad35130cd8a0 100644 --- a/drivers/serial/mfd.c +++ b/drivers/serial/mfd.c | |||
@@ -172,6 +172,9 @@ static ssize_t port_show_regs(struct file *file, char __user *user_buf, | |||
172 | len += snprintf(buf + len, HSU_REGS_BUFSIZE - len, | 172 | len += snprintf(buf + len, HSU_REGS_BUFSIZE - len, |
173 | "DIV: \t\t0x%08x\n", serial_in(up, UART_DIV)); | 173 | "DIV: \t\t0x%08x\n", serial_in(up, UART_DIV)); |
174 | 174 | ||
175 | if (len > HSU_REGS_BUFSIZE) | ||
176 | len = HSU_REGS_BUFSIZE; | ||
177 | |||
175 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, len); | 178 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
176 | kfree(buf); | 179 | kfree(buf); |
177 | return ret; | 180 | return ret; |
@@ -219,6 +222,9 @@ static ssize_t dma_show_regs(struct file *file, char __user *user_buf, | |||
219 | len += snprintf(buf + len, HSU_REGS_BUFSIZE - len, | 222 | len += snprintf(buf + len, HSU_REGS_BUFSIZE - len, |
220 | "D0TSR: \t\t0x%08x\n", chan_readl(chan, HSU_CH_D3TSR)); | 223 | "D0TSR: \t\t0x%08x\n", chan_readl(chan, HSU_CH_D3TSR)); |
221 | 224 | ||
225 | if (len > HSU_REGS_BUFSIZE) | ||
226 | len = HSU_REGS_BUFSIZE; | ||
227 | |||
222 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, len); | 228 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
223 | kfree(buf); | 229 | kfree(buf); |
224 | return ret; | 230 | return ret; |