[libvirt] [PATCH 5/9] virfile: Resolve Coverity RESOURCE_LEAK

Eric Blake eblake at redhat.com
Fri Sep 12 04:01:23 UTC 2014


On 09/11/2014 06:06 PM, John Ferlan wrote:
> With the virGetGroupList() change in place - Coverity further complains
> that if we fail to virFork(), the groups will be leaked - which aha seems
> to be the case. Adjust the logic to save off the -errno, free the groups,
> and then return the value we saved
> 
> Signed-off-by: John Ferlan <jferlan at redhat.com>
> ---
>  src/util/virfile.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)

ACK

> 
> diff --git a/src/util/virfile.c b/src/util/virfile.c
> index 7c506c9..b3b8be2 100644
> --- a/src/util/virfile.c
> +++ b/src/util/virfile.c
> @@ -2000,8 +2000,11 @@ virFileOpenForked(const char *path, int openflags, mode_t mode,
>      }
>  
>      pid = virFork();
> -    if (pid < 0)
> -        return -errno;
> +    if (pid < 0) {
> +        ret = -errno;
> +        VIR_FREE(groups);
> +        return ret;
> +    }
>  
>      if (pid == 0) {
>  
> 

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 539 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20140911/04553273/attachment-0001.sig>


More information about the libvir-list mailing list