summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAndrew Morton <akpm@linux-foundation.org>2011-04-12 16:13:31 -0700
committerGreg Kroah-Hartman <gregkh@suse.de>2011-04-19 17:00:48 -0700
commit70a5f52165bd04cf3b33f30d5d234be28dcf29d4 (patch)
tree5cccc910017e5ff7131a68f47865a998cd7cc9f3 /drivers
parent7e5b58bcbcb3d7518389c1d82fb6e926f5a9f72c (diff)
kmsg: properly support writev to avoid interleaved printk lines fix
make `len' size_t, avoid multiple-assignments. Cc: Kay Sievers <kay.sievers@vrfy.org> Cc: Lennart Poettering <lennart@poettering.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/char/mem.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/drivers/char/mem.c b/drivers/char/mem.c
index 78923a9f534..8fc04b4f311 100644
--- a/drivers/char/mem.c
+++ b/drivers/char/mem.c
@@ -810,11 +810,11 @@ static ssize_t kmsg_writev(struct kiocb *iocb, const struct iovec *iv,
unsigned long count, loff_t pos)
{
char *line, *p;
- int len, i;
+ int i;
ssize_t ret = -EFAULT;
+ size_t len = iov_length(iv, count);
- len = iov_length(iv, count);
- line = p = kmalloc(len + 1, GFP_KERNEL);
+ line = kmalloc(len + 1, GFP_KERNEL);
if (line == NULL)
return -ENOMEM;
@@ -822,6 +822,7 @@ static ssize_t kmsg_writev(struct kiocb *iocb, const struct iovec *iv,
* copy all vectors into a single string, to ensure we do
* not interleave our log line with other printk calls
*/
+ p = line;
for (i = 0; i < count; i++) {
if (copy_from_user(p, iv[i].iov_base, iv[i].iov_len))
goto out;