Commit 50f97a1f authored by Sarah Bailey's avatar Sarah Bailey Committed by Greg Kroah-Hartman

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: default avatarSarah Bailey <saharabeara@gmail.com>
Signed-off-by: default avatarDavid Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 4ef2e23f
...@@ -553,6 +553,7 @@ static ssize_t ep_aio_read_retry(struct kiocb *iocb) ...@@ -553,6 +553,7 @@ static ssize_t ep_aio_read_retry(struct kiocb *iocb)
{ {
struct kiocb_priv *priv = iocb->private; struct kiocb_priv *priv = iocb->private;
ssize_t len, total; ssize_t len, total;
void *to_copy;
int i; int i;
/* we "retry" to get the right mm context for this: */ /* we "retry" to get the right mm context for this: */
...@@ -560,10 +561,11 @@ static ssize_t ep_aio_read_retry(struct kiocb *iocb) ...@@ -560,10 +561,11 @@ static ssize_t ep_aio_read_retry(struct kiocb *iocb)
/* copy stuff into user buffers */ /* copy stuff into user buffers */
total = priv->actual; total = priv->actual;
len = 0; len = 0;
to_copy = priv->buf;
for (i=0; i < priv->nr_segs; i++) { for (i=0; i < priv->nr_segs; i++) {
ssize_t this = min((ssize_t)(priv->iv[i].iov_len), total); 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) if (len == 0)
len = -EFAULT; len = -EFAULT;
break; break;
...@@ -571,6 +573,7 @@ static ssize_t ep_aio_read_retry(struct kiocb *iocb) ...@@ -571,6 +573,7 @@ static ssize_t ep_aio_read_retry(struct kiocb *iocb)
total -= this; total -= this;
len += this; len += this;
to_copy += this;
if (total == 0) if (total == 0)
break; break;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment