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