[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 13/53] vhost-user-rng: Back up vqs before cleaning up vhost_dev
From: |
Michael S. Tsirkin |
Subject: |
[PULL 13/53] vhost-user-rng: Back up vqs before cleaning up vhost_dev |
Date: |
Thu, 2 Mar 2023 03:25:11 -0500 |
From: Akihiko Odaki <akihiko.odaki@daynix.com>
vhost_dev_cleanup() clears vhost_dev so back up its vqs member to free
the memory pointed by the member.
Fixes: 821d28b88f ("vhost-user-rng: Add vhost-user-rng implementation")
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
Message-Id: <20230130140516.78078-1-akihiko.odaki@daynix.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/virtio/vhost-user-rng.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/hw/virtio/vhost-user-rng.c b/hw/virtio/vhost-user-rng.c
index 201a39e220..efc54cd3fb 100644
--- a/hw/virtio/vhost-user-rng.c
+++ b/hw/virtio/vhost-user-rng.c
@@ -229,6 +229,7 @@ static void vu_rng_device_realize(DeviceState *dev, Error
**errp)
return;
vhost_dev_init_failed:
+ g_free(rng->vhost_dev.vqs);
virtio_delete_queue(rng->req_vq);
virtio_add_queue_failed:
virtio_cleanup(vdev);
@@ -239,12 +240,12 @@ static void vu_rng_device_unrealize(DeviceState *dev)
{
VirtIODevice *vdev = VIRTIO_DEVICE(dev);
VHostUserRNG *rng = VHOST_USER_RNG(dev);
+ struct vhost_virtqueue *vhost_vqs = rng->vhost_dev.vqs;
vu_rng_set_status(vdev, 0);
vhost_dev_cleanup(&rng->vhost_dev);
- g_free(rng->vhost_dev.vqs);
- rng->vhost_dev.vqs = NULL;
+ g_free(vhost_vqs);
virtio_delete_queue(rng->req_vq);
virtio_cleanup(vdev);
vhost_user_cleanup(&rng->vhost_user);
--
MST
- [PULL 00/53] virtio,pc,pci: features, cleanups, fixes, Michael S. Tsirkin, 2023/03/02
- [PULL 01/53] hw/smbios: fix field corruption in type 4 table, Michael S. Tsirkin, 2023/03/02
- [PULL 02/53] Revert "x86: don't let decompressed kernel image clobber setup_data", Michael S. Tsirkin, 2023/03/02
- [PULL 04/53] Revert "x86: re-initialize RNG seed when selecting kernel", Michael S. Tsirkin, 2023/03/02
- [PULL 03/53] Revert "x86: do not re-randomize RNG seed on snapshot load", Michael S. Tsirkin, 2023/03/02
- [PULL 05/53] Revert "x86: reinitialize RNG seed on system reboot", Michael S. Tsirkin, 2023/03/02
- [PULL 09/53] virtio-net: clear guest_announce feature if no cvq backend, Michael S. Tsirkin, 2023/03/02
- [PULL 11/53] vhost-user-gpio: Configure vhost_dev when connecting, Michael S. Tsirkin, 2023/03/02
- [PULL 16/53] docs: vhost-user: replace _SLAVE_ with _BACKEND_, Michael S. Tsirkin, 2023/03/02
- [PULL 07/53] Revert "x86: return modified setup_data only if read as memory, not as file", Michael S. Tsirkin, 2023/03/02
- [PULL 13/53] vhost-user-rng: Back up vqs before cleaning up vhost_dev,
Michael S. Tsirkin <=
- [PULL 17/53] libvhost-user: Adopt new backend naming, Michael S. Tsirkin, 2023/03/02
- [PULL 10/53] backends/vhost-user: remove the ioeventfd check, Michael S. Tsirkin, 2023/03/02
- [PULL 12/53] vhost-user-i2c: Back up vqs before cleaning up vhost_dev, Michael S. Tsirkin, 2023/03/02
- [PULL 14/53] virtio-rng-pci: fix transitional migration compat for vectors, Michael S. Tsirkin, 2023/03/02
- [PULL 08/53] Revert "hw/i386: pass RNG seed via setup_data entry", Michael S. Tsirkin, 2023/03/02
- [PULL 15/53] hw/timer/hpet: Fix expiration time overflow, Michael S. Tsirkin, 2023/03/02
- [PULL 06/53] Revert "x86: use typedef for SetupData struct", Michael S. Tsirkin, 2023/03/02