Message ID | 1575856810-9388-4-git-send-email-pannengyuan@huawei.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | virtio: fix memory leak in virtio-balloon/virtio-serial-bus | expand |
diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c index 3325904..f63dc46 100644 --- a/hw/char/virtio-serial-bus.c +++ b/hw/char/virtio-serial-bus.c @@ -1126,9 +1126,17 @@ static void virtio_serial_device_unrealize(DeviceState *dev, Error **errp) { VirtIODevice *vdev = VIRTIO_DEVICE(dev); VirtIOSerial *vser = VIRTIO_SERIAL(dev); + int i; QLIST_REMOVE(vser, next); + virtio_queue_cleanup(vser->c_ivq); + virtio_queue_cleanup(vser->c_ovq); + for (i = 0; i < vser->bus.max_nr_ports; i++) { + virtio_queue_cleanup(vser->ivqs[i]); + virtio_queue_cleanup(vser->ovqs[i]); + } + g_free(vser->ivqs); g_free(vser->ovqs); g_free(vser->ports_map);