diff options
author | Guillaume Chazarain <guichaz@yahoo.fr> | 2006-01-08 12:02:43 +0300 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-01-09 07:13:53 +0300 |
commit | cd140a5c1f456f50897af4a2e9a23d228a5fe719 (patch) | |
tree | 24170cf30ce2c5d3129c9b535942c4c52231a042 /drivers/char/mem.c | |
parent | 025510cd20f4c35c3958bea133d96c9bd7c6ef9e (diff) | |
download | linux-cd140a5c1f456f50897af4a2e9a23d228a5fe719.tar.xz |
[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: Guillaume Chazarain <guichaz@yahoo.fr>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/char/mem.c')
-rw-r--r-- | drivers/char/mem.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/char/mem.c b/drivers/char/mem.c index 91dd669273e0..a85f3a361442 100644 --- a/drivers/char/mem.c +++ b/drivers/char/mem.c @@ -817,7 +817,7 @@ static ssize_t kmsg_write(struct file * file, const char __user * buf, size_t count, loff_t *ppos) { char *tmp; - int ret; + ssize_t ret; tmp = kmalloc(count + 1, GFP_KERNEL); if (tmp == NULL) @@ -826,6 +826,9 @@ static ssize_t kmsg_write(struct file * file, const char __user * buf, if (!copy_from_user(tmp, buf, count)) { tmp[count] = 0; ret = printk("%s", tmp); + if (ret > count) + /* printk can add a prefix */ + ret = count; } kfree(tmp); return ret; |