[libvirt] [PATCH 3/3] xenconfig: Resolve Coverity RESOURCE_LEAK
Ján Tomko
jtomko at redhat.com
Fri Aug 22 15:51:43 UTC 2014
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 at 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20140822/fa0f84e0/attachment-0001.sig>
More information about the libvir-list
mailing list