Commit cd140a5c authored by Guillaume Chazarain's avatar Guillaume Chazarain Committed by Linus Torvalds

[PATCH] kmsg_write: don't return printk return value

kmsg_write returns with printk, so some programs may be confused by a
successful write() with a return value different than the buffer length.

# /bin/echo something > /dev/kmsg
/bin/echo: write error: Inappropriate ioctl for device

The drawbacks is that the printk return value can no more be quickly
checked from userspace.
Signed-off-by: default avatarGuillaume Chazarain <guichaz@yahoo.fr>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 025510cd
...@@ -817,7 +817,7 @@ static ssize_t kmsg_write(struct file * file, const char __user * buf, ...@@ -817,7 +817,7 @@ static ssize_t kmsg_write(struct file * file, const char __user * buf,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
char *tmp; char *tmp;
int ret; ssize_t ret;
tmp = kmalloc(count + 1, GFP_KERNEL); tmp = kmalloc(count + 1, GFP_KERNEL);
if (tmp == NULL) if (tmp == NULL)
...@@ -826,6 +826,9 @@ static ssize_t kmsg_write(struct file * file, const char __user * buf, ...@@ -826,6 +826,9 @@ static ssize_t kmsg_write(struct file * file, const char __user * buf,
if (!copy_from_user(tmp, buf, count)) { if (!copy_from_user(tmp, buf, count)) {
tmp[count] = 0; tmp[count] = 0;
ret = printk("%s", tmp); ret = printk("%s", tmp);
if (ret > count)
/* printk can add a prefix */
ret = count;
} }
kfree(tmp); kfree(tmp);
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