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>
---
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;
}
--
2.39.3
_______________________________________________
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-leave@lists.libvirt.org
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@oracle.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 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@redhat.com>
_______________________________________________
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-leave@lists.libvirt.org
© 2016 - 2026 Red Hat, Inc.