]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: hotplug: Don't access srcPriv when it's not allocated
authorPeter Krempa <pkrempa@redhat.com>
Tue, 3 Jul 2018 08:45:34 +0000 (10:45 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 3 Jul 2018 14:42:14 +0000 (16:42 +0200)
The private data of a virStorageSource which is backing an iSCSI hostdev
may be NULL if no authentication is present. The code handling the
hotplug would attempt to extract the authentication info stored in
'secinfo' without checking if it is allocated which resulted in a crash.

Here we opt the easy way to check if srcPriv is not NULL so that we
don't duplicate all the logic which selects whether the disk source has
a secret.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1597550

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
src/qemu/qemu_hotplug.c

index fcd8eb0ffad1f72352c9f925dc3ece7c5278f306..075f2fb72eb0de6a1ec75e8a0974fe1dce369a74 100644 (file)
@@ -2240,7 +2240,8 @@ qemuDomainAttachHostSCSIDevice(virQEMUDriverPtr driver,
     if (scsisrc->protocol == VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI) {
         qemuDomainStorageSourcePrivatePtr srcPriv =
             QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(scsisrc->u.iscsi.src);
-        secinfo = srcPriv->secinfo;
+        if (srcPriv)
+            secinfo = srcPriv->secinfo;
     }
 
     if (secinfo && secinfo->type == VIR_DOMAIN_SECRET_INFO_TYPE_AES) {