[libvirt] [PATCH 2/6] Fix possible memory leak in phyp_driver.c
John Ferlan
jferlan at redhat.com
Mon Jan 13 16:32:25 UTC 2014
On 01/13/2014 11:12 AM, Pavel Hrdina wrote:
> There could be a memory leak caused by "managed_system" string, if any
> error occurs before "managed_system" is assigned into
> "phyp_driver->managed_system". The "managed_system" string wouldn't be
> freed at all. The better way is free the "managed_system" instead
> of the one assigned in the "phyp_driver".
>
> This has been found by coverity.
>
> Signed-off-by: Pavel Hrdina <phrdina at redhat.com>
> ---
> src/phyp/phyp_driver.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c
> index 32165ed..6833e44 100644
> --- a/src/phyp/phyp_driver.c
> +++ b/src/phyp/phyp_driver.c
> @@ -1153,9 +1153,11 @@ phypConnectOpen(virConnectPtr conn,
> return VIR_DRV_OPEN_SUCCESS;
>
> failure:
> + if (conn->uri->path)
> + VIR_FREE(managed_system);
> +
Since managed_system is declared = NULL, so you could just drop the 'if'
condition...
> if (phyp_driver != NULL) {
> virObjectUnref(phyp_driver->caps);
> - VIR_FREE(phyp_driver->managed_system);
> VIR_FREE(phyp_driver);
not found by Coverity, but phyp_driver->xmlopt needs a 'virObjectUnref'
as well
ACK with the changes
John
> }
>
>
More information about the libvir-list
mailing list