From 4ea2f43f28e30050bc99fe3134b6b679f3bf5b22 Mon Sep 17 00:00:00 2001 From: Wu Fengguang Date: Mon, 14 Dec 2009 17:57:57 -0800 Subject: [PATCH] /dev/mem: remove redundant test on len The len test in write_kmem() is always true, so can be reduced. Signed-off-by: Wu Fengguang Acked-by: Andi Kleen Cc: Marcelo Tosatti Cc: Greg Kroah-Hartman Cc: Mark Brown Cc: Johannes Berg Cc: Avi Kivity Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/char/mem.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/char/mem.c b/drivers/char/mem.c index fba76fb55abf..f0a90590cb1a 100644 --- a/drivers/char/mem.c +++ b/drivers/char/mem.c @@ -581,14 +581,12 @@ static ssize_t write_kmem(struct file * file, const char __user * buf, 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; -- 2.20.1