[libvirt] [PATCH 1/3] conf: Alter when ctxt->node is set

John Ferlan jferlan at redhat.com
Thu Sep 20 21:34:36 UTC 2018


In virDomainMemoryDefParseXML and virDomainVideoDefParseXML if
the VIR_ALLOC fails and NULL is returned, then the alteration
to ctxt->node isn't reversed.

Found by Coverity

Signed-off-by: John Ferlan <jferlan at redhat.com>
---
 src/conf/domain_conf.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 1ee43950ae..9911d56130 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -15089,11 +15089,11 @@ virDomainVideoDefParseXML(virDomainXMLOptionPtr xmlopt,
     char *vgamem = NULL;
     char *primary = NULL;
 
-    ctxt->node = node;
-
     if (!(def = virDomainVideoDefNew()))
         return NULL;
 
+    ctxt->node = node;
+
     cur = node->children;
     while (cur != NULL) {
         if (cur->type == XML_ELEMENT_NODE) {
@@ -15830,11 +15830,11 @@ virDomainMemoryDefParseXML(virDomainXMLOptionPtr xmlopt,
     virDomainMemoryDefPtr def;
     int val;
 
-    ctxt->node = memdevNode;
-
     if (VIR_ALLOC(def) < 0)
         return NULL;
 
+    ctxt->node = memdevNode;
+
     if (!(tmp = virXMLPropString(memdevNode, "model"))) {
         virReportError(VIR_ERR_XML_ERROR, "%s",
                        _("missing memory model"));
-- 
2.17.1




More information about the libvir-list mailing list