Skip to content

Commit

Permalink
gadgetfs: Fixed bug in ep_aio_read_retry.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Sarah Bailey authored and Greg Kroah-Hartman committed Feb 23, 2007
1 parent 4ef2e23 commit 50f97a1
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion drivers/usb/gadget/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -553,24 +553,27 @@ static ssize_t ep_aio_read_retry(struct kiocb *iocb)
{
struct kiocb_priv *priv = iocb->private;
ssize_t len, total;
void *to_copy;
int i;

/* we "retry" to get the right mm context for this: */

/* copy stuff into user buffers */
total = priv->actual;
len = 0;
to_copy = priv->buf;
for (i=0; i < priv->nr_segs; i++) {
ssize_t this = min((ssize_t)(priv->iv[i].iov_len), total);

if (copy_to_user(priv->iv[i].iov_base, priv->buf, this)) {
if (copy_to_user(priv->iv[i].iov_base, to_copy, this)) {
if (len == 0)
len = -EFAULT;
break;
}

total -= this;
len += this;
to_copy += this;
if (total == 0)
break;
}
Expand Down

0 comments on commit 50f97a1

Please sign in to comment.