Re: [PATCH] conf: domain_conf: cleanup def in case of errors

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

 



On 1/11/24 6:57 AM, Shaleen Bathla wrote:
Just like in rest of the function virDomainFSDefParseXML,
use goto error so that def will be cleaned up in error cases.

Signed-off-by: Shaleen Bathla <shaleen.bathla@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 be57a1981e7d..5d55d2acdace 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -8866,23 +8866,23 @@ virDomainFSDefParseXML(virDomainXMLOption *xmlopt,
              goto error;
if ((n = virXPathNodeSet("./idmap/uid", ctxt, &uid_nodes)) < 0)
-            return NULL;
+            goto error;
if (n) {
              def->idmap.uidmap = virDomainIdmapDefParseXML(ctxt, uid_nodes, n);
              if (!def->idmap.uidmap)
-                return NULL;
+                goto error;
def->idmap.nuidmap = n;
          }
if ((n = virXPathNodeSet("./idmap/gid", ctxt, &gid_nodes)) < 0)
-            return NULL;
+            goto error;
if (n) {
              def->idmap.gidmap = virDomainIdmapDefParseXML(ctxt, gid_nodes, n);
              if (!def->idmap.gidmap)
-                return NULL;
+                goto error;
def->idmap.ngidmap = n;
          }

It might be worthwhile to introduce an automatic cleanup function for virDomainFSDef and remove the gotos from this function completely, but this patch fixes the immediate issue.

Reviewed-by: Jonathon Jongsma <jjongsma@xxxxxxxxxx>

_______________________________________________
Devel mailing list -- devel@xxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxx




[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