No behavior change. 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 | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) --- linux-mm.orig/drivers/char/mem.c 2009-09-10 21:59:39.000000000 +0800 +++ linux-mm/drivers/char/mem.c 2009-09-10 22:00:12.000000000 +0800 @@ -131,6 +131,7 @@ static ssize_t read_mem(struct file * fi size_t count, loff_t *ppos) { unsigned long p = *ppos; + unsigned long ret; ssize_t read, sz; char *ptr; @@ -169,12 +170,10 @@ static ssize_t read_mem(struct file * fi if (!ptr) return -EFAULT; - if (copy_to_user(buf, ptr, sz)) { - unxlate_dev_mem_ptr(p, ptr); - return -EFAULT; - } - + ret = copy_to_user(buf, ptr, sz); unxlate_dev_mem_ptr(p, ptr); + if (ret) + return -EFAULT; buf += sz; p += sz; @@ -232,16 +231,14 @@ static ssize_t write_mem(struct file * f } copied = copy_from_user(ptr, buf, sz); + unxlate_dev_mem_ptr(p, ptr); if (copied) { written += sz - copied; - unxlate_dev_mem_ptr(p, ptr); if (written) break; return -EFAULT; } - unxlate_dev_mem_ptr(p, ptr); - buf += sz; p += sz; count -= sz; -- -- 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/