[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH 3/3] xenconfig: Resolve Coverity RESOURCE_LEAK



On 08/22/2014 05:28 PM, John Ferlan wrote:
> Since '337a13628' - Coverity complains that 'net' is VIR_ALLOC()'d, but
> on various 'cleanup' exit paths from the code there is no corresponding
> cleanup.  Since 'net' is eventually appended onto a list of nets we don't
> want to delete the last one - be sure to set it to NULL, but still call
> the free function in cleanup
> 
> Signed-off-by: John Ferlan <jferlan redhat com>
> ---
>  src/xenconfig/xen_common.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/src/xenconfig/xen_common.c b/src/xenconfig/xen_common.c
> index 398e9ec..c487feb 100644
> --- a/src/xenconfig/xen_common.c
> +++ b/src/xenconfig/xen_common.c
> @@ -949,6 +949,7 @@ xenParseVif(virConfPtr conf, virDomainDefPtr def)
>  
>              if (VIR_APPEND_ELEMENT(def->nets, def->nnets, net) < 0)
>                  goto cleanup;
> +            net = NULL;

This bit should not be necessary. VIR_APPEND_ELEMENT expands to
virInsertElementsN with clearOriginal=true

>  
>          skipnic:
>              list = list->next;
> @@ -960,6 +961,7 @@ xenParseVif(virConfPtr conf, virDomainDefPtr def)
>      return 0;
>  
>   cleanup:
> +    virDomainNetDefFree(net);
>      VIR_FREE(script);
>      return -1;
>  }
> 

ACK

Jan

Attachment: signature.asc
Description: OpenPGP digital signature


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]