diff options
-rw-r--r-- | fs/nfs/idmap.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/fs/nfs/idmap.c b/fs/nfs/idmap.c index c56fc7d5a46e..d93e071b900c 100644 --- a/fs/nfs/idmap.c +++ b/fs/nfs/idmap.c | |||
@@ -358,17 +358,15 @@ idmap_pipe_upcall(struct file *filp, struct rpc_pipe_msg *msg, | |||
358 | char __user *dst, size_t buflen) | 358 | char __user *dst, size_t buflen) |
359 | { | 359 | { |
360 | char *data = (char *)msg->data + msg->copied; | 360 | char *data = (char *)msg->data + msg->copied; |
361 | ssize_t mlen = msg->len - msg->copied; | 361 | size_t mlen = min(msg->len, buflen); |
362 | ssize_t left; | 362 | unsigned long left; |
363 | |||
364 | if (mlen > buflen) | ||
365 | mlen = buflen; | ||
366 | 363 | ||
367 | left = copy_to_user(dst, data, mlen); | 364 | left = copy_to_user(dst, data, mlen); |
368 | if (left < 0) { | 365 | if (left == mlen) { |
369 | msg->errno = left; | 366 | msg->errno = -EFAULT; |
370 | return left; | 367 | return -EFAULT; |
371 | } | 368 | } |
369 | |||
372 | mlen -= left; | 370 | mlen -= left; |
373 | msg->copied += mlen; | 371 | msg->copied += mlen; |
374 | msg->errno = 0; | 372 | msg->errno = 0; |