Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 63196e98 authored by Binyamin Sharet's avatar Binyamin Sharet Committed by Felipe Balbi
Browse files

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: default avatarBinyamin Sharet <s.binyamin@gmail.com>
Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
parent 528d2813
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -606,7 +606,7 @@ ep_read_iter(struct kiocb *iocb, struct iov_iter *to)
	}
	if (is_sync_kiocb(iocb)) {
		value = ep_io(epdata, buf, len);
		if (value >= 0 && copy_to_iter(buf, value, to))
		if (value >= 0 && (copy_to_iter(buf, value, to) != value))
			value = -EFAULT;
	} else {
		struct kiocb_priv *priv = kzalloc(sizeof *priv, GFP_KERNEL);