The len test in write_kmem() is always true, so can be reduced. CC: Marcelo Tosatti CC: Greg Kroah-Hartman CC: Mark Brown CC: Johannes Berg CC: Avi Kivity Signed-off-by: Wu Fengguang --- drivers/char/mem.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) --- linux.orig/drivers/char/mem.c +++ linux/drivers/char/mem.c @@ -580,18 +580,16 @@ static ssize_t write_kmem(struct file * while (count > 0) { int len = count; if (len > PAGE_SIZE) len = PAGE_SIZE; - if (len) { - written = copy_from_user(kbuf, buf, len); - if (written) { - if (wrote + virtr) - break; - free_page((unsigned long)kbuf); - return -EFAULT; - } + written = copy_from_user(kbuf, buf, len); + if (written) { + if (wrote + virtr) + break; + free_page((unsigned long)kbuf); + return -EFAULT; } len = vwrite(kbuf, (char *)p, len); count -= len; buf += len; virtr += len; -- -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/