aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/char/mem.c28
1 files changed, 13 insertions, 15 deletions
diff --git a/drivers/char/mem.c b/drivers/char/mem.c
index 29c41f4418c0..26d0116b48d4 100644
--- a/drivers/char/mem.c
+++ b/drivers/char/mem.c
@@ -216,11 +216,9 @@ static ssize_t write_mem(struct file * file, const char __user * buf,
216 216
217 copied = copy_from_user(ptr, buf, sz); 217 copied = copy_from_user(ptr, buf, sz);
218 if (copied) { 218 if (copied) {
219 ssize_t ret; 219 written += sz - copied;
220 220 if (written)
221 ret = written + (sz - copied); 221 break;
222 if (ret)
223 return ret;
224 return -EFAULT; 222 return -EFAULT;
225 } 223 }
226 buf += sz; 224 buf += sz;
@@ -456,11 +454,9 @@ do_write_kmem(void *p, unsigned long realp, const char __user * buf,
456 454
457 copied = copy_from_user(ptr, buf, sz); 455 copied = copy_from_user(ptr, buf, sz);
458 if (copied) { 456 if (copied) {
459 ssize_t ret; 457 written += sz - copied;
460 458 if (written)
461 ret = written + (sz - copied); 459 break;
462 if (ret)
463 return ret;
464 return -EFAULT; 460 return -EFAULT;
465 } 461 }
466 buf += sz; 462 buf += sz;
@@ -514,11 +510,10 @@ static ssize_t write_kmem(struct file * file, const char __user * buf,
514 if (len) { 510 if (len) {
515 written = copy_from_user(kbuf, buf, len); 511 written = copy_from_user(kbuf, buf, len);
516 if (written) { 512 if (written) {
517 ssize_t ret; 513 if (wrote + virtr)
518 514 break;
519 free_page((unsigned long)kbuf); 515 free_page((unsigned long)kbuf);
520 ret = wrote + virtr + (len - written); 516 return -EFAULT;
521 return ret ? ret : -EFAULT;
522 } 517 }
523 } 518 }
524 len = vwrite(kbuf, (char *)p, len); 519 len = vwrite(kbuf, (char *)p, len);
@@ -563,8 +558,11 @@ static ssize_t write_port(struct file * file, const char __user * buf,
563 return -EFAULT; 558 return -EFAULT;
564 while (count-- > 0 && i < 65536) { 559 while (count-- > 0 && i < 65536) {
565 char c; 560 char c;
566 if (__get_user(c, tmp)) 561 if (__get_user(c, tmp)) {
562 if (tmp > buf)
563 break;
567 return -EFAULT; 564 return -EFAULT;
565 }
568 outb(c,i); 566 outb(c,i);
569 i++; 567 i++;
570 tmp++; 568 tmp++;