mirror of
https://github.com/torvalds/linux
synced 2024-09-20 11:07:02 +00:00
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>
This commit is contained in:
parent
7e5b58bcbc
commit
70a5f52165
|
@ -810,11 +810,11 @@ static ssize_t kmsg_writev(struct kiocb *iocb, const struct iovec *iv,
|
||||||
unsigned long count, loff_t pos)
|
unsigned long count, loff_t pos)
|
||||||
{
|
{
|
||||||
char *line, *p;
|
char *line, *p;
|
||||||
int len, i;
|
int i;
|
||||||
ssize_t ret = -EFAULT;
|
ssize_t ret = -EFAULT;
|
||||||
|
size_t len = iov_length(iv, count);
|
||||||
|
|
||||||
len = iov_length(iv, count);
|
line = kmalloc(len + 1, GFP_KERNEL);
|
||||||
line = p = kmalloc(len + 1, GFP_KERNEL);
|
|
||||||
if (line == NULL)
|
if (line == NULL)
|
||||||
return -ENOMEM;
|
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
|
* copy all vectors into a single string, to ensure we do
|
||||||
* not interleave our log line with other printk calls
|
* not interleave our log line with other printk calls
|
||||||
*/
|
*/
|
||||||
|
p = line;
|
||||||
for (i = 0; i < count; i++) {
|
for (i = 0; i < count; i++) {
|
||||||
if (copy_from_user(p, iv[i].iov_base, iv[i].iov_len))
|
if (copy_from_user(p, iv[i].iov_base, iv[i].iov_len))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
Loading…
Reference in a new issue