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

gadgetfs: Fixed bug in ep_aio_read_retry.

I don't think the current code works with multiple iovecs.
The original would just copy the first part of priv->buf
over and over into multiple iovecs.

Signed-off-by: Sarah Bailey <saharabeara@gmail.com>
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

authored by

Sarah Bailey and committed by
Greg Kroah-Hartman
50f97a1f 4ef2e23f

+4 -1
+4 -1
drivers/usb/gadget/inode.c
··· 553 553 { 554 554 struct kiocb_priv *priv = iocb->private; 555 555 ssize_t len, total; 556 + void *to_copy; 556 557 int i; 557 558 558 559 /* we "retry" to get the right mm context for this: */ ··· 561 560 /* copy stuff into user buffers */ 562 561 total = priv->actual; 563 562 len = 0; 563 + to_copy = priv->buf; 564 564 for (i=0; i < priv->nr_segs; i++) { 565 565 ssize_t this = min((ssize_t)(priv->iv[i].iov_len), total); 566 566 567 - if (copy_to_user(priv->iv[i].iov_base, priv->buf, this)) { 567 + if (copy_to_user(priv->iv[i].iov_base, to_copy, this)) { 568 568 if (len == 0) 569 569 len = -EFAULT; 570 570 break; ··· 573 571 574 572 total -= this; 575 573 len += this; 574 + to_copy += this; 576 575 if (total == 0) 577 576 break; 578 577 }