aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/fuse/file.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index c989f0e9456..05dedddf428 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -475,7 +475,7 @@ static int fuse_get_user_pages(struct fuse_req *req, const char __user *buf,
475 475
476 nbytes = min(nbytes, (unsigned) FUSE_MAX_PAGES_PER_REQ << PAGE_SHIFT); 476 nbytes = min(nbytes, (unsigned) FUSE_MAX_PAGES_PER_REQ << PAGE_SHIFT);
477 npages = (nbytes + offset + PAGE_SIZE - 1) >> PAGE_SHIFT; 477 npages = (nbytes + offset + PAGE_SIZE - 1) >> PAGE_SHIFT;
478 npages = min(npages, FUSE_MAX_PAGES_PER_REQ); 478 npages = min(max(npages, 1), FUSE_MAX_PAGES_PER_REQ);
479 down_read(&current->mm->mmap_sem); 479 down_read(&current->mm->mmap_sem);
480 npages = get_user_pages(current, current->mm, user_addr, npages, write, 480 npages = get_user_pages(current, current->mm, user_addr, npages, write,
481 0, req->pages, NULL); 481 0, req->pages, NULL);
@@ -506,7 +506,6 @@ static ssize_t fuse_direct_io(struct file *file, const char __user *buf,
506 return -EINTR; 506 return -EINTR;
507 507
508 while (count) { 508 while (count) {
509 size_t tmp;
510 size_t nres; 509 size_t nres;
511 size_t nbytes = min(count, nmax); 510 size_t nbytes = min(count, nmax);
512 int err = fuse_get_user_pages(req, buf, nbytes, !write); 511 int err = fuse_get_user_pages(req, buf, nbytes, !write);
@@ -514,8 +513,8 @@ static ssize_t fuse_direct_io(struct file *file, const char __user *buf,
514 res = err; 513 res = err;
515 break; 514 break;
516 } 515 }
517 tmp = (req->num_pages << PAGE_SHIFT) - req->page_offset; 516 nbytes = (req->num_pages << PAGE_SHIFT) - req->page_offset;
518 nbytes = min(nbytes, tmp); 517 nbytes = min(count, nbytes);
519 if (write) 518 if (write)
520 nres = fuse_send_write(req, file, inode, pos, nbytes); 519 nres = fuse_send_write(req, file, inode, pos, nbytes);
521 else 520 else