From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33638) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cQpAG-0007dV-Nm for qemu-devel@nongnu.org; Tue, 10 Jan 2017 00:40:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cQpAG-0005hO-36 for qemu-devel@nongnu.org; Tue, 10 Jan 2017 00:40:08 -0500 Received: from mail.kernel.org ([198.145.29.136]:48034) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cQpAF-0005fs-T6 for qemu-devel@nongnu.org; Tue, 10 Jan 2017 00:40:08 -0500 Date: Tue, 10 Jan 2017 07:40:03 +0200 From: "Michael S. Tsirkin" Message-ID: <1484026704-28027-18-git-send-email-mst@redhat.com> References: <1484026704-28027-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1484026704-28027-1-git-send-email-mst@redhat.com> Subject: [Qemu-devel] [PULL 17/41] virtio-crypto-pci: add check for cryptodev object List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Maydell , Gonglei From: Gonglei We must assure each virtio crypto pci device has an vaild cryptodev backend object. Signed-off-by: Gonglei Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio-crypto-pci.c | 5 +++++ 1 file changed, 5 insertions(+) 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); -- MST