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

Re: [Xen-devel] [PATCH v5 03/17] libxl: fix memory leak in libxl_list_vcpu



Dario Faggioli writes ("[PATCH v5 03/17] libxl: fix memory leak in 
libxl_list_vcpu"):
> more specifically, of the cpumap inside libxl_vcpuinfo, in case
> of failure after it has been allocated.
> 
> While at it, use the correct libxl memory allocation wrapper for
> calloc() in there and turn the function into using the new LOGE()
> logging style.
...
> diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
> index 0cb7ca9..028106b 100644
> --- a/tools/libxl/libxl.c
> +++ b/tools/libxl/libxl.c
> @@ -4527,31 +4527,31 @@ const libxl_version_info* 
> libxl_get_version_info(libxl_ctx *ctx)
>  libxl_vcpuinfo *libxl_list_vcpu(libxl_ctx *ctx, uint32_t domid,
>                                         int *nb_vcpu, int *nr_cpus_out)
>  {
> +    GC_INIT(ctx);
>      libxl_vcpuinfo *ptr, *ret;
>      xc_domaininfo_t domaininfo;
>      xc_vcpuinfo_t vcpuinfo;
>  
>      if (xc_domain_getinfolist(ctx->xch, domid, 1, &domaininfo) != 1) {
> -        LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "getting infolist");
> +        LOGE(ERROR, "getting infolist");
>          return NULL;
>      }

Would it be better to initialise ret to NULL and then change this
"return NULL" to "goto err" ?

But it's good as far as it goes.

Acked-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.