xenfs/xenbus: report partial reads/writes correctly
copy_(to|from)_user return the number of uncopied bytes, so a successful return is 0, and any non-zero result indicates some degree of failure. Reported-by: "Jun Zhu (Intern)" <Jun.Zhu@citrix.com> Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
This commit is contained in:
parent
6280f190da
commit
fb27cfbcbd
@ -142,7 +142,7 @@ static ssize_t xenbus_file_read(struct file *filp,
|
|||||||
i += sz - ret;
|
i += sz - ret;
|
||||||
rb->cons += sz - ret;
|
rb->cons += sz - ret;
|
||||||
|
|
||||||
if (ret != sz) {
|
if (ret != 0) {
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
i = -EFAULT;
|
i = -EFAULT;
|
||||||
goto out;
|
goto out;
|
||||||
@ -453,7 +453,7 @@ static ssize_t xenbus_file_write(struct file *filp,
|
|||||||
|
|
||||||
ret = copy_from_user(u->u.buffer + u->len, ubuf, len);
|
ret = copy_from_user(u->u.buffer + u->len, ubuf, len);
|
||||||
|
|
||||||
if (ret == len) {
|
if (ret != 0) {
|
||||||
rc = -EFAULT;
|
rc = -EFAULT;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user