Blame SOURCES/kvm-virtio-serial-bus-Unset-hotplug-handler-when-unreali.patch

76daa3
From 23b4ce3b1ab27196f75bbaa31ef8d00df9eb2597 Mon Sep 17 00:00:00 2001
76daa3
From: Ladi Prosek <lprosek@redhat.com>
76daa3
Date: Mon, 5 Jun 2017 13:24:43 +0200
76daa3
Subject: [PATCH 09/13] virtio-serial-bus: Unset hotplug handler when unrealize
76daa3
76daa3
RH-Author: Ladi Prosek <lprosek@redhat.com>
76daa3
Message-id: <20170605132443.13592-1-lprosek@redhat.com>
76daa3
Patchwork-id: 75481
76daa3
O-Subject: [RHEL-7.4 qemu-kvm-rhev PATCH] virtio-serial-bus: Unset hotplug handler when unrealize
76daa3
Bugzilla: 1458782
76daa3
RH-Acked-by: Fam Zheng <famz@redhat.com>
76daa3
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
76daa3
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
76daa3
76daa3
Virtio serial device controls the lifetime of virtio-serial-bus and
76daa3
virtio-serial-bus links back to the device via its hotplug-handler
76daa3
property. This extra ref-count prevents the device from getting
76daa3
finalized, leaving the VirtIODevice memory listener registered and
76daa3
leading to use-after-free later on.
76daa3
76daa3
This patch addresses the same issue as Fam Zheng's
76daa3
"virtio-scsi: Unset hotplug handler when unrealize"
76daa3
only for a different virtio device.
76daa3
76daa3
Cc: qemu-stable@nongnu.org
76daa3
Signed-off-by: Ladi Prosek <lprosek@redhat.com>
76daa3
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
76daa3
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
76daa3
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
76daa3
Reviewed-by: Fam Zheng <famz@redhat.com>
76daa3
(cherry-picked from commit f811f97040a48358b456b46ecbc9167f0131034f)
76daa3
Signed-off-by: Ladi Prosek <lprosek@redhat.com>
76daa3
76daa3
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
76daa3
---
76daa3
 hw/char/virtio-serial-bus.c | 3 +++
76daa3
 1 file changed, 3 insertions(+)
76daa3
76daa3
diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c
76daa3
index d797a67..aa9c11a 100644
76daa3
--- a/hw/char/virtio-serial-bus.c
76daa3
+++ b/hw/char/virtio-serial-bus.c
76daa3
@@ -1121,6 +1121,9 @@ static void virtio_serial_device_unrealize(DeviceState *dev, Error **errp)
76daa3
         timer_free(vser->post_load->timer);
76daa3
         g_free(vser->post_load);
76daa3
     }
76daa3
+
76daa3
+    qbus_set_hotplug_handler(BUS(&vser->bus), NULL, errp);
76daa3
+
76daa3
     virtio_cleanup(vdev);
76daa3
 }
76daa3
 
76daa3
-- 
76daa3
1.8.3.1
76daa3