[libvirt] [PATCH 1/2] virDomainDiskSourceFormatInternal: Avoid leaking @childBuf

Daniel P. Berrangé berrange at redhat.com
Tue Feb 20 11:33:19 UTC 2018


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 at 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 at 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 :|




More information about the libvir-list mailing list