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 <[email protected]>
---
  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 <[email protected]>

_______________________________________________
Devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to