NFS: Fix use of copy_to_user() in idmap_pipe_upcall
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>
This commit is contained in:
parent
369af0f116
commit
a661b77fc1
@ -358,17 +358,15 @@ idmap_pipe_upcall(struct file *filp, struct rpc_pipe_msg *msg,
|
|||||||
char __user *dst, size_t buflen)
|
char __user *dst, size_t buflen)
|
||||||
{
|
{
|
||||||
char *data = (char *)msg->data + msg->copied;
|
char *data = (char *)msg->data + msg->copied;
|
||||||
ssize_t mlen = msg->len - msg->copied;
|
size_t mlen = min(msg->len, buflen);
|
||||||
ssize_t left;
|
unsigned long left;
|
||||||
|
|
||||||
if (mlen > buflen)
|
|
||||||
mlen = buflen;
|
|
||||||
|
|
||||||
left = copy_to_user(dst, data, mlen);
|
left = copy_to_user(dst, data, mlen);
|
||||||
if (left < 0) {
|
if (left == mlen) {
|
||||||
msg->errno = left;
|
msg->errno = -EFAULT;
|
||||||
return left;
|
return -EFAULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
mlen -= left;
|
mlen -= left;
|
||||||
msg->copied += mlen;
|
msg->copied += mlen;
|
||||||
msg->errno = 0;
|
msg->errno = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user