/dev/mem: remove redundant test on len
authorWu Fengguang <[email protected]>
Tue, 15 Dec 2009 01:57:57 +0000 (17:57 -0800)
committerLinus Torvalds <[email protected]>
Tue, 15 Dec 2009 16:53:11 +0000 (08:53 -0800)
The len test in write_kmem() is always true, so can be reduced.

Signed-off-by: Wu Fengguang <[email protected]>
Acked-by: Andi Kleen <[email protected]>
Cc: Marcelo Tosatti <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: Mark Brown <[email protected]>
Cc: Johannes Berg <[email protected]>
Cc: Avi Kivity <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
drivers/char/mem.c

index fba76fb55abfd302bbd87e6433ed858b8b5d2c4d..f0a90590cb1aa63a06afc31a1d6980b3e1dcebfd 100644 (file)
@@ -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;