]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: Add extra checks for secret destroy API's
authorJohn Ferlan <jferlan@redhat.com>
Tue, 10 May 2016 18:26:44 +0000 (14:26 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Tue, 10 May 2016 19:48:08 +0000 (15:48 -0400)
Remove the possibility that a NULL hostdev->privateData or a
disk->privateData could crash libvirtd by checking for NULL
before dereferencing for the secinfo structure in the
qemuDomainSecret{Disk|Hostdev}Destroy functions. The hostdevPriv
could be NULL if qemuProcessNetworkPrepareDevices adds a new
hostdev during virDomainNetGetActualHostdev that then gets
inserted via virDomainHostdevInsert. The hostdevPriv was added
by commit id '27726d8' and is currently only used by scsi hostdev.

src/qemu/qemu_domain.c

index 93f0a01b4e40e360cb80d7ee76ccd2aaa2c8e697..0cddb86b51d72b8241026aa15fdd77f0aa9adfcb 100644 (file)
@@ -903,7 +903,7 @@ qemuDomainSecretDiskDestroy(virDomainDiskDefPtr disk)
 {
     qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
 
-    if (!diskPriv->secinfo)
+    if (!diskPriv || !diskPriv->secinfo)
         return;
 
     qemuDomainSecretInfoFree(&diskPriv->secinfo);
@@ -964,7 +964,7 @@ qemuDomainSecretHostdevDestroy(virDomainHostdevDefPtr hostdev)
     qemuDomainHostdevPrivatePtr hostdevPriv =
         QEMU_DOMAIN_HOSTDEV_PRIVATE(hostdev);
 
-    if (!hostdevPriv->secinfo)
+    if (!hostdevPriv || !hostdevPriv->secinfo)
         return;
 
     qemuDomainSecretInfoFree(&hostdevPriv->secinfo);