Skip to content

Commit

Permalink
rds: Make rds_message_copy_from_user() return 0 on success.
Browse files Browse the repository at this point in the history
Commit 083735f ("rds: switch rds_message_copy_from_user() to iov_iter")
breaks rds_message_copy_from_user() semantics on success, and causes it
to return nbytes copied, when it should return 0.  This commit fixes that bug.

Signed-off-by: Sowmini Varadhan <sowmini.varadhan@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Sowmini Varadhan authored and David S. Miller committed Feb 8, 2015
1 parent 11ac119 commit d0a47d3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions net/rds/message.c
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ struct rds_message *rds_message_map_pages(unsigned long *page_addrs, unsigned in

int rds_message_copy_from_user(struct rds_message *rm, struct iov_iter *from)
{
unsigned long to_copy;
unsigned long to_copy, nbytes;
unsigned long sg_off;
struct scatterlist *sg;
int ret = 0;
Expand All @@ -293,9 +293,9 @@ int rds_message_copy_from_user(struct rds_message *rm, struct iov_iter *from)
sg->length - sg_off);

rds_stats_add(s_copy_from_user, to_copy);
ret = copy_page_from_iter(sg_page(sg), sg->offset + sg_off,
to_copy, from);
if (ret != to_copy)
nbytes = copy_page_from_iter(sg_page(sg), sg->offset + sg_off,
to_copy, from);
if (nbytes != to_copy)
return -EFAULT;

sg_off += to_copy;
Expand Down

0 comments on commit d0a47d3

Please sign in to comment.