[libvirt] [PATCH 2/2] parallels: Resolve some resource leaks
Peter Krempa
pkrempa at redhat.com
Tue Jan 22 15:34:12 UTC 2013
On 01/22/13 15:20, 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.
> ---
> src/parallels/parallels_driver.c | 30 +++++++++++++++++++-----------
> 1 file changed, 19 insertions(+), 11 deletions(-)
>
> diff --git a/src/parallels/parallels_driver.c b/src/parallels/parallels_driver.c
> index ea193af..8beab2c 100644
> --- a/src/parallels/parallels_driver.c
> +++ b/src/parallels/parallels_driver.c
> @@ -304,8 +304,9 @@ parallelsAddVideoInfo(virDomainDefPtr def, virJSONValuePtr value)
>
> no_memory:
> virReportOOMError();
> -cleanup:
> + VIR_FREE(accel);
> virDomainVideoDefFree(video);
> +cleanup:
Hm, this label is used only in error cases. "error:" would be probably
better here. But it is pre-existing.
> return -1;
> }
>
> @@ -1809,58 +1810,58 @@ static int parallelsApplyIfaceParams(parallelsDomObjPtr pdom,
> if (!create && oldnet->type != newnet->type) {
> virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
> _("Changing network type is not supported"));
[...]
>
> @@ -1902,15 +1903,22 @@ static int parallelsApplyIfaceParams(parallelsDomObjPtr pdom,
> is_changed = true;
> }
>
> + if (create)
> + VIR_FREE(oldnet);
> +
> if (!create && !is_changed) {
> /* nothing changed - no need to run prlctl */
> return 0;
> }
>
> if (virCommandRun(cmd, NULL))
> - return -1;
> + goto error;
>
> return 0;
Shouldn't cmd be freed here too?
> +error:
> + if (create)
> + VIR_FREE(oldnet);
> + return -1;
> }
>
> static int
>
Peter
More information about the libvir-list
mailing list