Commit a9589811 authored by Dan Carpenter's avatar Dan Carpenter Committed by Greg Kroah-Hartman

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: default avatarDan Carpenter <error27@gmail.com>
Acked-by: default avatarFeng Tang <feng.tang@intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent de838a93
...@@ -172,6 +172,9 @@ static ssize_t port_show_regs(struct file *file, char __user *user_buf, ...@@ -172,6 +172,9 @@ static ssize_t port_show_regs(struct file *file, char __user *user_buf,
len += snprintf(buf + len, HSU_REGS_BUFSIZE - len, len += snprintf(buf + len, HSU_REGS_BUFSIZE - len,
"DIV: \t\t0x%08x\n", serial_in(up, UART_DIV)); "DIV: \t\t0x%08x\n", serial_in(up, UART_DIV));
if (len > HSU_REGS_BUFSIZE)
len = HSU_REGS_BUFSIZE;
ret = simple_read_from_buffer(user_buf, count, ppos, buf, len); ret = simple_read_from_buffer(user_buf, count, ppos, buf, len);
kfree(buf); kfree(buf);
return ret; return ret;
...@@ -219,6 +222,9 @@ static ssize_t dma_show_regs(struct file *file, char __user *user_buf, ...@@ -219,6 +222,9 @@ static ssize_t dma_show_regs(struct file *file, char __user *user_buf,
len += snprintf(buf + len, HSU_REGS_BUFSIZE - len, len += snprintf(buf + len, HSU_REGS_BUFSIZE - len,
"D0TSR: \t\t0x%08x\n", chan_readl(chan, HSU_CH_D3TSR)); "D0TSR: \t\t0x%08x\n", chan_readl(chan, HSU_CH_D3TSR));
if (len > HSU_REGS_BUFSIZE)
len = HSU_REGS_BUFSIZE;
ret = simple_read_from_buffer(user_buf, count, ppos, buf, len); ret = simple_read_from_buffer(user_buf, count, ppos, buf, len);
kfree(buf); kfree(buf);
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment