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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 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

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux