aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBinyamin Sharet <s.binyamin@gmail.com>2016-07-07 15:22:04 -0400
committerFelipe Balbi <felipe.balbi@linux.intel.com>2016-08-11 08:09:46 -0400
commit63196e989699ddffb4e3d30ca8c3567d408820f4 (patch)
tree38e89f838dbf362ebad3ead74e292c5aecc2980c
parent528d28138f91009f230903bd89ccd44719667831 (diff)
usb: gadget: fix check in sync read from ep in gadgetfs
When reading synchronously from a non-zero endpoint, gadgetfs will return -EFAULT even if the read succeeds, due to a bad check of the copy_to_iter() return value. This fix compares the return value of copy_to_iter to the amount of bytes that was passed, and only fails if they are not the same. Signed-off-by: Binyamin Sharet <s.binyamin@gmail.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
-rw-r--r--drivers/usb/gadget/legacy/inode.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/usb/gadget/legacy/inode.c b/drivers/usb/gadget/legacy/inode.c
index aa3707bdebb4..8560f2fe3af5 100644
--- a/drivers/usb/gadget/legacy/inode.c
+++ b/drivers/usb/gadget/legacy/inode.c
@@ -606,7 +606,7 @@ ep_read_iter(struct kiocb *iocb, struct iov_iter *to)
606 } 606 }
607 if (is_sync_kiocb(iocb)) { 607 if (is_sync_kiocb(iocb)) {
608 value = ep_io(epdata, buf, len); 608 value = ep_io(epdata, buf, len);
609 if (value >= 0 && copy_to_iter(buf, value, to)) 609 if (value >= 0 && (copy_to_iter(buf, value, to) != value))
610 value = -EFAULT; 610 value = -EFAULT;
611 } else { 611 } else {
612 struct kiocb_priv *priv = kzalloc(sizeof *priv, GFP_KERNEL); 612 struct kiocb_priv *priv = kzalloc(sizeof *priv, GFP_KERNEL);