[libvirt] [PATCH v2] parallels: Resolve some resource leaks

Peter Krempa pkrempa at redhat.com
Wed Jan 23 13:19:29 UTC 2013


On 01/22/13 21:10, John Ferlan wrote:
> Be sure to VIR_FREE(accel) and moved virDomainVideoDefFree() within no_memory
> label to be consistent
>
> Resolve resource leak in parallelsApplyIfaceParams() when the 'oldnet' is
> allocated locally. Also virCommandFree(cmd) as necessary.
>
> ---
>
> This is a followup patch to:
>
> https://www.redhat.com/archives/libvir-list/2013-January/msg01565.html
>
> Changes in v2:
>     Change label from cleanup to error
>     Add calls to virCommandFree()
>
>   src/parallels/parallels_driver.c | 40 +++++++++++++++++++++++++---------------
>   1 file changed, 25 insertions(+), 15 deletions(-)
>

[...]

>       }
>
> @@ -1901,15 +1902,24 @@ static int parallelsApplyIfaceParams(parallelsDomObjPtr pdom,
>           is_changed = true;
>       }
>
> +    if (create)
> +        VIR_FREE(oldnet);
> +
>       if (!create && !is_changed) {
>           /* nothing changed - no need to run prlctl */
> +        virCommandFree(cmd);
>           return 0;
>       }
>
>       if (virCommandRun(cmd, NULL))
> -        return -1;
> +        goto error;
>
>       return 0;

Um, I probably wasn't clear enough. The virCommand cmd needs to be freed 
also on success.

> +error:

I'd go for a cleanup label here and add a "ret" variable to indicate 
success or failure.

> +    if (create)
> +        VIR_FREE(oldnet);
> +    virCommandFree(cmd);
> +    return -1;
>   }
>
>   static int
>

Peter




More information about the libvir-list mailing list