[ Upstream commit
f01d35a15fa04162a58b95970fc01fa70ec9dacd ]
AIO_PREAD requests call ->aio_read() with iovec on caller's stack, so if
we are going to access it asynchronously, we'd better get ourselves
a copy - the one on kernel stack of aio_run_iocb() won't be there
anymore. function/f_fs.c take care of doing that, legacy/inode.c
doesn't...
Cc: stable@vger.kernel.org
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
if (total == 0)
break;
}
-
return len;
}
aio_complete(iocb, ret, ret);
kfree(priv->buf);
+ kfree(priv->iv);
kfree(priv);
}
*/
if (priv->iv == NULL || unlikely(req->actual == 0)) {
kfree(req->buf);
+ kfree(priv->iv);
kfree(priv);
iocb->private = NULL;
/* aio_complete() reports bytes-transferred _and_ faults */
struct usb_request *req;
ssize_t value;
- priv = kmalloc(sizeof *priv, GFP_KERNEL);
+ priv = kzalloc(sizeof *priv, GFP_KERNEL);
if (!priv) {
value = -ENOMEM;
fail:
}
iocb->private = priv;
priv->iocb = iocb;
- priv->iv = iv;
+ if (iv) {
+ priv->iv = kmemdup(iv, nr_segs * sizeof(struct iovec),
+ GFP_KERNEL);
+ if (!priv->iv) {
+ kfree(priv);
+ goto fail;
+ }
+ }
priv->nr_segs = nr_segs;
INIT_WORK(&priv->work, ep_user_copy_worker);
mutex_unlock(&epdata->lock);
if (unlikely(value)) {
+ kfree(priv->iv);
kfree(priv);
put_ep(epdata);
} else