]> git.proxmox.com Git - mirror_qemu.git/commitdiff
virtio-serial-bus: Unset hotplug handler when unrealize
authorLadi Prosek <lprosek@redhat.com>
Tue, 30 May 2017 08:59:43 +0000 (10:59 +0200)
committerMichael Roth <mdroth@linux.vnet.ibm.com>
Thu, 3 Aug 2017 21:01:28 +0000 (16:01 -0500)
Virtio serial device controls the lifetime of virtio-serial-bus and
virtio-serial-bus links back to the device via its hotplug-handler
property. This extra ref-count prevents the device from getting
finalized, leaving the VirtIODevice memory listener registered and
leading to use-after-free later on.

This patch addresses the same issue as Fam Zheng's
"virtio-scsi: Unset hotplug handler when unrealize"
only for a different virtio device.

Cc: qemu-stable@nongnu.org
Signed-off-by: Ladi Prosek <lprosek@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Fam Zheng <famz@redhat.com>
(cherry picked from commit f811f97040a48358b456b46ecbc9167f0131034f)
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
hw/char/virtio-serial-bus.c

index d797a6796ede8bb2c781fcfbc9bc0eb952142a6b..aa9c11ae92036b9f890c9ddbc774cc6f94521fb5 100644 (file)
@@ -1121,6 +1121,9 @@ static void virtio_serial_device_unrealize(DeviceState *dev, Error **errp)
         timer_free(vser->post_load->timer);
         g_free(vser->post_load);
     }
+
+    qbus_set_hotplug_handler(BUS(&vser->bus), NULL, errp);
+
     virtio_cleanup(vdev);
 }