]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
conf: Fix crash in virDomainDefCompatibleDevice
authorJohn Ferlan <jferlan@redhat.com>
Thu, 1 Mar 2018 12:08:32 +0000 (07:08 -0500)
committerJohn Ferlan <jferlan@redhat.com>
Thu, 1 Mar 2018 13:05:36 +0000 (08:05 -0500)
Commit id 'edae027c' blindly assumed that the passed @oldDev
parameter would not be NULL when calling virDomainDeviceGetInfo;
however, commit id 'b6a264e8' passed NULL for AttachDevice
callers under the premise that there wouldn't be a device
to check/update against.

Signed-off-by: John Ferlan <jferlan@redhat.com>
src/conf/domain_conf.c

index d96b012b98f0b8dd035c827a5793473e7c4ad486..fcafc8b2fafe0b90e4ee2671fe1377240d6cdc9f 100644 (file)
@@ -27417,9 +27417,12 @@ virDomainDefCompatibleDevice(virDomainDefPtr def,
 {
     virDomainCompatibleDeviceData data = {
         .newInfo = virDomainDeviceGetInfo(dev),
-        .oldInfo = virDomainDeviceGetInfo(oldDev),
+        .oldInfo = NULL,
     };
 
+    if (oldDev)
+        data.oldInfo = virDomainDeviceGetInfo(oldDev);
+
     if (!virDomainDefHasUSB(def) &&
         def->os.type != VIR_DOMAIN_OSTYPE_EXE &&
         virDomainDeviceIsUSB(dev)) {