Blame SOURCES/libvirt-conf-fix-crash-when-hotplug-a-channel-chr-device-with-no-target.patch

9119d9
From dd17f33dab431a06a7b8b76ac39bcd04d4eca8f2 Mon Sep 17 00:00:00 2001
9119d9
Message-Id: <dd17f33dab431a06a7b8b76ac39bcd04d4eca8f2@dist-git>
9119d9
From: Luyao Huang <lhuang@redhat.com>
9119d9
Date: Tue, 13 Jan 2015 10:36:47 +0100
9119d9
Subject: [PATCH] conf: fix crash when hotplug a channel chr device with no
9119d9
 target
9119d9
MIME-Version: 1.0
9119d9
Content-Type: text/plain; charset=UTF-8
9119d9
Content-Transfer-Encoding: 8bit
9119d9
9119d9
https://bugzilla.redhat.com/show_bug.cgi?id=1181408
9119d9
9119d9
When we try to hotplug a channel chr device with no target, we
9119d9
will get success (which should fail) in virDomainChrDefParseXML,
9119d9
because we use goto cleanup this place and return an incomplete
9119d9
definition (with no target). In qemuDomainAttachChrDevice,
9119d9
we add it to the domain definition, but fail to remove it from
9119d9
there when chardev-add fails, because virDomainChrRemove
9119d9
matches chardevices according to the target name.
9119d9
The device definition is then freed in qemuDomainAttachDeviceFlags,
9119d9
leaving a stale pointer in the domain definition.
9119d9
9119d9
Signed-off-by: Luyao Huang <lhuang@redhat.com>
9119d9
Signed-off-by: Ján Tomko <jtomko@redhat.com>
9119d9
(cherry picked from commit fba7173f7236c705344aa84bf9715074abdc6ea7)
9119d9
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9119d9
---
9119d9
 src/conf/domain_conf.c | 2 +-
9119d9
 1 file changed, 1 insertion(+), 1 deletion(-)
9119d9
9119d9
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
9119d9
index bbd204a..fed87f0 100644
9119d9
--- a/src/conf/domain_conf.c
9119d9
+++ b/src/conf/domain_conf.c
9119d9
@@ -8272,7 +8272,7 @@ virDomainChrDefParseXML(xmlXPathContextPtr ctxt,
9119d9
 
9119d9
     if (!seenTarget &&
9119d9
         ((def->targetType = virDomainChrDefaultTargetType(def->deviceType)) < 0))
9119d9
-        goto cleanup;
9119d9
+        goto error;
9119d9
 
9119d9
     if (virDomainChrSourceDefParseXML(&def->source, node->children, flags, def,
9119d9
                                       ctxt, vmSeclabels, nvmSeclabels) < 0)
9119d9
-- 
9119d9
2.2.1
9119d9