* [PATCH] vhost-vsock: detach the virqueue element in case of error
@ 2022-02-28 9:50 Stefano Garzarella
2022-03-01 9:30 ` Stefan Hajnoczi
0 siblings, 1 reply; 2+ messages in thread
From: Stefano Garzarella @ 2022-02-28 9:50 UTC (permalink / raw)
To: qemu-devel
Cc: VictorV, Stefano Garzarella, qemu-stable, stefanha,
Michael S. Tsirkin
In vhost_vsock_common_send_transport_reset(), if an element popped from
the virtqueue is invalid, we should call virtqueue_detach_element() to
detach it from the virtqueue before freeing its memory.
Fixes: fc0b9b0e1c ("vhost-vsock: add virtio sockets device")
Cc: qemu-stable@nongnu.org
Reported-by: VictorV <vv474172261@gmail.com>
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
---
hw/virtio/vhost-vsock-common.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/hw/virtio/vhost-vsock-common.c b/hw/virtio/vhost-vsock-common.c
index 3f3771274e..ed706681ac 100644
--- a/hw/virtio/vhost-vsock-common.c
+++ b/hw/virtio/vhost-vsock-common.c
@@ -153,19 +153,23 @@ static void vhost_vsock_common_send_transport_reset(VHostVSockCommon *vvc)
if (elem->out_num) {
error_report("invalid vhost-vsock event virtqueue element with "
"out buffers");
- goto out;
+ goto err;
}
if (iov_from_buf(elem->in_sg, elem->in_num, 0,
&event, sizeof(event)) != sizeof(event)) {
error_report("vhost-vsock event virtqueue element is too short");
- goto out;
+ goto err;
}
virtqueue_push(vq, elem, sizeof(event));
virtio_notify(VIRTIO_DEVICE(vvc), vq);
-out:
+ g_free(elem);
+ return;
+
+err:
+ virtqueue_detach_element(vq, elem, 0);
g_free(elem);
}
--
2.35.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] vhost-vsock: detach the virqueue element in case of error
2022-02-28 9:50 [PATCH] vhost-vsock: detach the virqueue element in case of error Stefano Garzarella
@ 2022-03-01 9:30 ` Stefan Hajnoczi
0 siblings, 0 replies; 2+ messages in thread
From: Stefan Hajnoczi @ 2022-03-01 9:30 UTC (permalink / raw)
To: Stefano Garzarella; +Cc: VictorV, qemu-stable, qemu-devel, Michael S. Tsirkin
[-- Attachment #1: Type: text/plain, Size: 646 bytes --]
On Mon, Feb 28, 2022 at 10:50:58AM +0100, Stefano Garzarella wrote:
> In vhost_vsock_common_send_transport_reset(), if an element popped from
> the virtqueue is invalid, we should call virtqueue_detach_element() to
> detach it from the virtqueue before freeing its memory.
>
> Fixes: fc0b9b0e1c ("vhost-vsock: add virtio sockets device")
> Cc: qemu-stable@nongnu.org
> Reported-by: VictorV <vv474172261@gmail.com>
> Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
> ---
> hw/virtio/vhost-vsock-common.c | 10 +++++++---
> 1 file changed, 7 insertions(+), 3 deletions(-)
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-03-01 9:34 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-28 9:50 [PATCH] vhost-vsock: detach the virqueue element in case of error Stefano Garzarella
2022-03-01 9:30 ` Stefan Hajnoczi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).