147b37
From b5eaca77959775ffce33c459a06f0dcacee5338d Mon Sep 17 00:00:00 2001
147b37
Message-Id: <b5eaca77959775ffce33c459a06f0dcacee5338d@dist-git>
147b37
From: John Ferlan <jferlan@redhat.com>
147b37
Date: Thu, 1 Mar 2018 07:08:32 -0500
147b37
Subject: [PATCH] conf: Fix crash in virDomainDefCompatibleDevice
147b37
MIME-Version: 1.0
147b37
Content-Type: text/plain; charset=UTF-8
147b37
Content-Transfer-Encoding: 8bit
147b37
147b37
Commit id 'edae027c' blindly assumed that the passed @oldDev
147b37
parameter would not be NULL when calling virDomainDeviceGetInfo;
147b37
however, commit id 'b6a264e8' passed NULL for AttachDevice
147b37
callers under the premise that there wouldn't be a device
147b37
to check/update against.
147b37
147b37
Signed-off-by: John Ferlan <jferlan@redhat.com>
147b37
(cherry picked from commit 5535856f0e31aa6abf4cda11b5c53c0f164680f0)
147b37
147b37
https://bugzilla.redhat.com/show_bug.cgi?id=1557922
147b37
147b37
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
147b37
Reviewed-by: Ján Tomko <jtomko@redhat.com>
147b37
---
147b37
 src/conf/domain_conf.c | 5 ++++-
147b37
 1 file changed, 4 insertions(+), 1 deletion(-)
147b37
147b37
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
147b37
index f21c776ccd..7f4da169d6 100644
147b37
--- a/src/conf/domain_conf.c
147b37
+++ b/src/conf/domain_conf.c
147b37
@@ -27202,9 +27202,12 @@ virDomainDefCompatibleDevice(virDomainDefPtr def,
147b37
 {
147b37
     virDomainCompatibleDeviceData data = {
147b37
         .newInfo = virDomainDeviceGetInfo(dev),
147b37
-        .oldInfo = virDomainDeviceGetInfo(oldDev),
147b37
+        .oldInfo = NULL,
147b37
     };
147b37
 
147b37
+    if (oldDev)
147b37
+        data.oldInfo = virDomainDeviceGetInfo(oldDev);
147b37
+
147b37
     if (!virDomainDefHasUSB(def) &&
147b37
         def->os.type != VIR_DOMAIN_OSTYPE_EXE &&
147b37
         virDomainDeviceIsUSB(dev)) {
147b37
-- 
147b37
2.17.0
147b37