Skip to content

Commit

Permalink
kmsg: properly support writev to avoid interleaved printk lines fix
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Andrew Morton authored and Greg Kroah-Hartman committed Apr 20, 2011
1 parent 7e5b58b commit 70a5f52
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions drivers/char/mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -810,18 +810,19 @@ 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;

/*
* 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;
Expand Down

0 comments on commit 70a5f52

Please sign in to comment.