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

Re: [libvirt] [PATCH 2/6] Fix possible memory leak in phyp_driver.c




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 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
>      }
>  
> 


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