conf: domain_conf: cleanup def in case of errors

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@oracle.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
This commit is contained in:
Shaleen Bathla 2024-01-11 18:27:54 +05:30 committed by Jonathon Jongsma
parent 6fa82fd8e2
commit 9ef6fee129

View File

@ -8866,23 +8866,23 @@ virDomainFSDefParseXML(virDomainXMLOption *xmlopt,
goto error; goto error;
if ((n = virXPathNodeSet("./idmap/uid", ctxt, &uid_nodes)) < 0) if ((n = virXPathNodeSet("./idmap/uid", ctxt, &uid_nodes)) < 0)
return NULL; goto error;
if (n) { if (n) {
def->idmap.uidmap = virDomainIdmapDefParseXML(ctxt, uid_nodes, n); def->idmap.uidmap = virDomainIdmapDefParseXML(ctxt, uid_nodes, n);
if (!def->idmap.uidmap) if (!def->idmap.uidmap)
return NULL; goto error;
def->idmap.nuidmap = n; def->idmap.nuidmap = n;
} }
if ((n = virXPathNodeSet("./idmap/gid", ctxt, &gid_nodes)) < 0) if ((n = virXPathNodeSet("./idmap/gid", ctxt, &gid_nodes)) < 0)
return NULL; goto error;
if (n) { if (n) {
def->idmap.gidmap = virDomainIdmapDefParseXML(ctxt, gid_nodes, n); def->idmap.gidmap = virDomainIdmapDefParseXML(ctxt, gid_nodes, n);
if (!def->idmap.gidmap) if (!def->idmap.gidmap)
return NULL; goto error;
def->idmap.ngidmap = n; def->idmap.ngidmap = n;
} }