]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: Tolerate storage source private data being NULL for hotplug SCSI hostdev
authorJohn Ferlan <jferlan@redhat.com>
Tue, 5 Dec 2017 21:03:34 +0000 (16:03 -0500)
committerJohn Ferlan <jferlan@redhat.com>
Wed, 13 Dec 2017 20:16:15 +0000 (15:16 -0500)
Commit id 'c5c96545' neglected to validate that the srcPriv was
non-NULL before dereferencing. Similar problem to what was fixed
by commit id '8056721c' but missed during multiple rebases and
code reworks.

src/qemu/qemu_hotplug.c

index 24631cb8f7e4987fe495ec0e15ee7f9b2e0f709a..c4f8c0fa4aedcb899481693f787edfef6ecf07c9 100644 (file)
@@ -2286,7 +2286,7 @@ qemuDomainAttachHostSCSIDevice(virConnectPtr conn,
     virDomainHostdevSubsysSCSIPtr scsisrc = &hostdev->source.subsys.u.scsi;
     virDomainHostdevSubsysSCSIiSCSIPtr iscsisrc = &scsisrc->u.iscsi;
     qemuDomainStorageSourcePrivatePtr srcPriv;
-    qemuDomainSecretInfoPtr secinfo;
+    qemuDomainSecretInfoPtr secinfo = NULL;
 
     if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE_SCSI_GENERIC)) {
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
@@ -2328,7 +2328,8 @@ qemuDomainAttachHostSCSIDevice(virConnectPtr conn,
         goto cleanup;
 
     srcPriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(iscsisrc->src);
-    secinfo = srcPriv->secinfo;
+    if (srcPriv)
+        secinfo = srcPriv->secinfo;
     if (secinfo && secinfo->type == VIR_DOMAIN_SECRET_INFO_TYPE_AES) {
         if (qemuBuildSecretInfoProps(secinfo, &secobjProps) < 0)
             goto cleanup;