virtio-scsi: Fix memory leak when realize failed
authorFam Zheng <famz@redhat.com>
Thu, 30 Oct 2014 11:50:26 +0000 (19:50 +0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 31 Oct 2014 10:29:02 +0000 (11:29 +0100)
Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
hw/scsi/virtio-scsi.c

index 7d40eccb0c37db178922c059464c18a93f5ccb99..235c2053da4f0a768d460814a0b6ebeca330b54c 100644 (file)
@@ -808,6 +808,7 @@ void virtio_scsi_common_realize(DeviceState *dev, Error **errp,
         error_setg(errp, "Invalid number of queues (= %" PRId32 "), "
                          "must be a positive integer less than %d.",
                    s->conf.num_queues, VIRTIO_PCI_QUEUE_MAX);
+        virtio_cleanup(vdev);
         return;
     }
     s->cmd_vqs = g_malloc0(s->conf.num_queues * sizeof(VirtQueue *));