aboutsummaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorBo Su <subo7@huawei.com>2015-03-18 09:42:12 +0000
committerPaolo Bonzini <pbonzini@redhat.com>2015-03-18 12:08:52 +0100
commit196d4fc56d824ccbbb58714e9ad0793053ef8260 (patch)
tree2763b408d0e0954d233f50627e3eaba52c024657 /hw
parent89d5cbddeeaf6bb4aa6a5ca4fbb443115abce4a2 (diff)
virtio-scsi-dataplane: fix memory leak in virtio_scsi_vring_init
if k->set_host_notifier failed, VirtIOSCSIVring *r will leak Signed-off-by: Bo Su <subo7@huawei.com> Message-Id: <1426671732-80213-1-git-send-email-subo7@huawei.com> Reviewed-by: Fam Zheng <famz@redhat.com> Reviewed-by: Gonglei <arei.gonglei@huawei.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'hw')
-rw-r--r--hw/scsi/virtio-scsi-dataplane.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/hw/scsi/virtio-scsi-dataplane.c b/hw/scsi/virtio-scsi-dataplane.c
index 3f40ff090f..c069cd764c 100644
--- a/hw/scsi/virtio-scsi-dataplane.c
+++ b/hw/scsi/virtio-scsi-dataplane.c
@@ -45,7 +45,7 @@ static VirtIOSCSIVring *virtio_scsi_vring_init(VirtIOSCSI *s,
{
BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(s)));
VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);
- VirtIOSCSIVring *r = g_slice_new(VirtIOSCSIVring);
+ VirtIOSCSIVring *r;
int rc;
/* Set up virtqueue notify */
@@ -56,6 +56,8 @@ static VirtIOSCSIVring *virtio_scsi_vring_init(VirtIOSCSI *s,
s->dataplane_fenced = true;
return NULL;
}
+
+ r = g_slice_new(VirtIOSCSIVring);
r->host_notifier = *virtio_queue_get_host_notifier(vq);
r->guest_notifier = *virtio_queue_get_guest_notifier(vq);
aio_set_event_notifier(s->ctx, &r->host_notifier, handler);