Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

rds: Make rds_message_copy_from_user() return 0 on success.

Commit 083735f4b01b ("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>

authored by

Sowmini Varadhan and committed by
David S. Miller
d0a47d32 11ac1199

+4 -4
+4 -4
net/rds/message.c
··· 266 266 267 267 int rds_message_copy_from_user(struct rds_message *rm, struct iov_iter *from) 268 268 { 269 - unsigned long to_copy; 269 + unsigned long to_copy, nbytes; 270 270 unsigned long sg_off; 271 271 struct scatterlist *sg; 272 272 int ret = 0; ··· 293 293 sg->length - sg_off); 294 294 295 295 rds_stats_add(s_copy_from_user, to_copy); 296 - ret = copy_page_from_iter(sg_page(sg), sg->offset + sg_off, 297 - to_copy, from); 298 - if (ret != to_copy) 296 + nbytes = copy_page_from_iter(sg_page(sg), sg->offset + sg_off, 297 + to_copy, from); 298 + if (nbytes != to_copy) 299 299 return -EFAULT; 300 300 301 301 sg_off += to_copy;