Skip to content

Commit

Permalink
/dev/mem: remove redundant test on len
Browse files Browse the repository at this point in the history
The len test in write_kmem() is always true, so can be reduced.

Signed-off-by: Wu Fengguang <fengguang.wu@intel.com>
Acked-by: Andi Kleen <ak@linux.intel.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>
Cc: Greg Kroah-Hartman <gregkh@suse.de>
Cc: Mark Brown <broonie@opensource.wolfsonmicro.com>
Cc: Johannes Berg <johannes@sipsolutions.net>
Cc: Avi Kivity <avi@qumranet.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Wu Fengguang authored and Linus Torvalds committed Dec 15, 2009
1 parent 659ace5 commit 4ea2f43
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions drivers/char/mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 4ea2f43

Please sign in to comment.