Skip to content

Commit

Permalink
xenfs/xenbus: report partial reads/writes correctly
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jeremy Fitzhardinge committed Aug 25, 2010
1 parent 6280f19 commit fb27cfb
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/xen/xenfs/xenbus.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ static ssize_t xenbus_file_read(struct file *filp,
i += sz - ret;
rb->cons += sz - ret;

if (ret != sz) {
if (ret != 0) {
if (i == 0)
i = -EFAULT;
goto out;
Expand Down Expand Up @@ -453,7 +453,7 @@ static ssize_t xenbus_file_write(struct file *filp,

ret = copy_from_user(u->u.buffer + u->len, ubuf, len);

if (ret == len) {
if (ret != 0) {
rc = -EFAULT;
goto out;
}
Expand Down

0 comments on commit fb27cfb

Please sign in to comment.