mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 19:21:31 -04:00
virtio, vhost: fixes, cleanups
fixes and cleanups all over the place Signed-off-by: Michael S. Tsirkin <[email protected]> -----BEGIN PGP SIGNATURE----- iQEcBAABAgAGBQJcPTc7AAoJECgfDbjSjVRpOEgH/Ahdx7VMYJtFsdmoJKiwhB7M jRRi9R903V9H87vl1BXy6dutHw+WONJtm6FSZ1ayNWlVmUmWS6vci+IUErr2uDrv KSG+dJMQLlF7t1dnLRwlLazvGa4/58+u0J459uKPQ5ckqwV5wXPjUS5Z0xF3ldxM Twz6vhYRGKCUc10YZm/WmsjlLROgaNtRya10PzAGVmXPzbCpvJfiojKWJER+Eigq JxWynTCm/YvIk824Ls9cDBVkDvb8GPS3blVbFnusR+D3ktvX7vLDPOsErGn4umVS nUm3/WiQALB9fKer+SsgcEGVh+fa06KIITK+IBblULmrAIT3CJdJp70UJBjfdTM= =DCkE -----END PGP SIGNATURE----- Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost Pull virtio/vhost fixes and cleanups from Michael Tsirkin: "Fixes and cleanups all over the place" * tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost: vhost/scsi: Use copy_to_iter() to send control queue response vhost: return EINVAL if iovecs size does not match the message size virtio-balloon: tweak config_changed implementation virtio: don't allocate vqs when names[i] = NULL virtio_pci: use queue idx instead of array idx to set up the vq virtio: document virtio_config_ops restrictions virtio: fix virtio_config_ops description
This commit is contained in:
commit
bb617b9b45
9 changed files with 126 additions and 60 deletions
|
|
@ -1127,16 +1127,18 @@ vhost_scsi_send_tmf_reject(struct vhost_scsi *vs,
|
|||
struct vhost_virtqueue *vq,
|
||||
struct vhost_scsi_ctx *vc)
|
||||
{
|
||||
struct virtio_scsi_ctrl_tmf_resp __user *resp;
|
||||
struct virtio_scsi_ctrl_tmf_resp rsp;
|
||||
struct iov_iter iov_iter;
|
||||
int ret;
|
||||
|
||||
pr_debug("%s\n", __func__);
|
||||
memset(&rsp, 0, sizeof(rsp));
|
||||
rsp.response = VIRTIO_SCSI_S_FUNCTION_REJECTED;
|
||||
resp = vq->iov[vc->out].iov_base;
|
||||
ret = __copy_to_user(resp, &rsp, sizeof(rsp));
|
||||
if (!ret)
|
||||
|
||||
iov_iter_init(&iov_iter, READ, &vq->iov[vc->out], vc->in, sizeof(rsp));
|
||||
|
||||
ret = copy_to_iter(&rsp, sizeof(rsp), &iov_iter);
|
||||
if (likely(ret == sizeof(rsp)))
|
||||
vhost_add_used_and_signal(&vs->dev, vq, vc->head, 0);
|
||||
else
|
||||
pr_err("Faulted on virtio_scsi_ctrl_tmf_resp\n");
|
||||
|
|
@ -1147,16 +1149,18 @@ vhost_scsi_send_an_resp(struct vhost_scsi *vs,
|
|||
struct vhost_virtqueue *vq,
|
||||
struct vhost_scsi_ctx *vc)
|
||||
{
|
||||
struct virtio_scsi_ctrl_an_resp __user *resp;
|
||||
struct virtio_scsi_ctrl_an_resp rsp;
|
||||
struct iov_iter iov_iter;
|
||||
int ret;
|
||||
|
||||
pr_debug("%s\n", __func__);
|
||||
memset(&rsp, 0, sizeof(rsp)); /* event_actual = 0 */
|
||||
rsp.response = VIRTIO_SCSI_S_OK;
|
||||
resp = vq->iov[vc->out].iov_base;
|
||||
ret = __copy_to_user(resp, &rsp, sizeof(rsp));
|
||||
if (!ret)
|
||||
|
||||
iov_iter_init(&iov_iter, READ, &vq->iov[vc->out], vc->in, sizeof(rsp));
|
||||
|
||||
ret = copy_to_iter(&rsp, sizeof(rsp), &iov_iter);
|
||||
if (likely(ret == sizeof(rsp)))
|
||||
vhost_add_used_and_signal(&vs->dev, vq, vc->head, 0);
|
||||
else
|
||||
pr_err("Faulted on virtio_scsi_ctrl_an_resp\n");
|
||||
|
|
|
|||
|
|
@ -1034,8 +1034,10 @@ ssize_t vhost_chr_write_iter(struct vhost_dev *dev,
|
|||
int type, ret;
|
||||
|
||||
ret = copy_from_iter(&type, sizeof(type), from);
|
||||
if (ret != sizeof(type))
|
||||
if (ret != sizeof(type)) {
|
||||
ret = -EINVAL;
|
||||
goto done;
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case VHOST_IOTLB_MSG:
|
||||
|
|
@ -1054,8 +1056,10 @@ ssize_t vhost_chr_write_iter(struct vhost_dev *dev,
|
|||
|
||||
iov_iter_advance(from, offset);
|
||||
ret = copy_from_iter(&msg, sizeof(msg), from);
|
||||
if (ret != sizeof(msg))
|
||||
if (ret != sizeof(msg)) {
|
||||
ret = -EINVAL;
|
||||
goto done;
|
||||
}
|
||||
if (vhost_process_iotlb_msg(dev, &msg)) {
|
||||
ret = -EFAULT;
|
||||
goto done;
|
||||
|
|
|
|||
Loading…
Reference in a new issue