Skip to content

Commit

Permalink
NFS: Fix use of copy_to_user() in idmap_pipe_upcall
Browse files Browse the repository at this point in the history
The idmap_pipe_upcall() function expects the copy_to_user() function to
return a negative error value if the call fails, but copy_to_user()
returns an unsigned long number of bytes that couldn't be copied.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
  • Loading branch information
Chuck Lever authored and Trond Myklebust committed Jan 30, 2008
1 parent 369af0f commit a661b77
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions fs/nfs/idmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -358,17 +358,15 @@ idmap_pipe_upcall(struct file *filp, struct rpc_pipe_msg *msg,
char __user *dst, size_t buflen)
{
char *data = (char *)msg->data + msg->copied;
ssize_t mlen = msg->len - msg->copied;
ssize_t left;

if (mlen > buflen)
mlen = buflen;
size_t mlen = min(msg->len, buflen);
unsigned long left;

left = copy_to_user(dst, data, mlen);
if (left < 0) {
msg->errno = left;
return left;
if (left == mlen) {
msg->errno = -EFAULT;
return -EFAULT;
}

mlen -= left;
msg->copied += mlen;
msg->errno = 0;
Expand Down

0 comments on commit a661b77

Please sign in to comment.