aboutsummaryrefslogtreecommitdiff
path: root/hw/virtio/virtio-crypto-pci.c
diff options
context:
space:
mode:
authorGonglei <arei.gonglei@huawei.com>2016-12-22 11:12:40 +0800
committerMichael S. Tsirkin <mst@redhat.com>2017-01-10 07:02:52 +0200
commit305f5131ac30b4a03e698bae0976f4cd24bb0a86 (patch)
tree9e3f3b4a8328a06c214efd49b64d8d1805a32035 /hw/virtio/virtio-crypto-pci.c
parent6138dbda5a4bfa6c724fd04b9225181d3a3c85a7 (diff)
downloadqemu-305f5131ac30b4a03e698bae0976f4cd24bb0a86.zip
qemu-305f5131ac30b4a03e698bae0976f4cd24bb0a86.tar.gz
qemu-305f5131ac30b4a03e698bae0976f4cd24bb0a86.tar.bz2
virtio-crypto-pci: add check for cryptodev object
We must assure each virtio crypto pci device has an vaild cryptodev backend object. Signed-off-by: Gonglei <arei.gonglei@huawei.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'hw/virtio/virtio-crypto-pci.c')
-rw-r--r--hw/virtio/virtio-crypto-pci.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/hw/virtio/virtio-crypto-pci.c b/hw/virtio/virtio-crypto-pci.c
index a1b0906..14bd12c 100644
--- a/hw/virtio/virtio-crypto-pci.c
+++ b/hw/virtio/virtio-crypto-pci.c
@@ -31,6 +31,11 @@ static void virtio_crypto_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp)
VirtIOCryptoPCI *vcrypto = VIRTIO_CRYPTO_PCI(vpci_dev);
DeviceState *vdev = DEVICE(&vcrypto->vdev);
+ if (vcrypto->vdev.conf.cryptodev == NULL) {
+ error_setg(errp, "'cryptodev' parameter expects a valid object");
+ return;
+ }
+
qdev_set_parent_bus(vdev, BUS(&vpci_dev->bus));
virtio_pci_force_virtio_1(vpci_dev);
object_property_set_bool(OBJECT(vdev), true, "realized", errp);