[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1287771688-14805-3-git-send-email-gregkh@suse.de>
Date: Fri, 22 Oct 2010 11:20:42 -0700
From: Greg Kroah-Hartman <gregkh@...e.de>
To: linux-kernel@...r.kernel.org
Cc: Dan Carpenter <error27@...il.com>,
Greg Kroah-Hartman <gregkh@...e.de>
Subject: [PATCH 03/49] serial: mfd: snprintf() returns largish values
From: Dan Carpenter <error27@...il.com>
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@...il.com>
Acked-by: Feng Tang <feng.tang@...el.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@...e.de>
---
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 5dff45c..ad35130 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,
len += snprintf(buf + len, HSU_REGS_BUFSIZE - len,
"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);
kfree(buf);
return ret;
@@ -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,
"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);
kfree(buf);
return ret;
--
1.7.2
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists