If formatting of storage encryption or private data fails we must
jump to the error label instead of returning immediately
otherwise @attrBuf and @childBuf might be leaked.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
src/conf/domain_conf.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index fdf5ad19e..b6ebe918d 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -22910,10 +22910,10 @@ virDomainDiskSourceFormatInternal(virBufferPtr buf,
* as we found it. */
if (src->encryption && src->encryptionInherited &&
virStorageEncryptionFormat(&childBuf, src->encryption) < 0)
- return -1;
+ goto error;
if (virDomainDiskSourceFormatPrivateData(&childBuf, src, flags, xmlopt) < 0)
- return -1;
+ goto error;
if (virXMLFormatElement(buf, "source", &attrBuf, &childBuf) < 0)
goto error;
--
2.16.1
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
On Tue, Feb 20, 2018 at 12:30:31PM +0100, Michal Privoznik wrote: > If formatting of storage encryption or private data fails we must > jump to the error label instead of returning immediately > otherwise @attrBuf and @childBuf might be leaked. > > Signed-off-by: Michal Privoznik <mprivozn@redhat.com> > --- > src/conf/domain_conf.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c > index fdf5ad19e..b6ebe918d 100644 > --- a/src/conf/domain_conf.c > +++ b/src/conf/domain_conf.c > @@ -22910,10 +22910,10 @@ virDomainDiskSourceFormatInternal(virBufferPtr buf, > * as we found it. */ > if (src->encryption && src->encryptionInherited && > virStorageEncryptionFormat(&childBuf, src->encryption) < 0) > - return -1; > + goto error; > > if (virDomainDiskSourceFormatPrivateData(&childBuf, src, flags, xmlopt) < 0) > - return -1; > + goto error; > > if (virXMLFormatElement(buf, "source", &attrBuf, &childBuf) < 0) > goto error; Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :| -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
© 2016 - 2025 Red Hat, Inc.