From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51027) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dFe2H-0001me-Km for qemu-devel@nongnu.org; Tue, 30 May 2017 06:05:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dFe2D-000076-GU for qemu-devel@nongnu.org; Tue, 30 May 2017 06:05:57 -0400 References: <20170530085943.18141-1-lprosek@redhat.com> From: Paolo Bonzini Message-ID: <15cd09a0-23a4-1f1f-d058-cd1778f70bb2@redhat.com> Date: Tue, 30 May 2017 12:05:48 +0200 MIME-Version: 1.0 In-Reply-To: <20170530085943.18141-1-lprosek@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] virtio-serial-bus: Unset hotplug handler when unrealize List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Ladi Prosek , qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, famz@redhat.com, mst@redhat.com On 30/05/2017 10:59, Ladi Prosek wrote: > 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 > --- > hw/char/virtio-serial-bus.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c > index d797a67..aa9c11a 100644 > --- a/hw/char/virtio-serial-bus.c > +++ b/hw/char/virtio-serial-bus.c > @@ -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); > } > > Reviewed-by: Paolo Bonzini