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

Re: [Xen-devel] [PATCH v2] xl: free bitmaps on exit



On Tue, Nov 27, 2018 at 11:06:08AM +0100, Olaf Hering wrote:
> Every invocation of xl via valgrind will show three leaks.
> Since libxl_bitmap_alloc uses NOGC, the caller has to free the memory
> after use. And since xl_ctx_free might be called before
> parse_global_config, also move the libxl_bitmap_init calls into
> xl_ctx_alloc.
> 
> Signed-off-by: Olaf Hering <olaf@xxxxxxxxx>
> ---
>  tools/xl/xl.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/tools/xl/xl.c b/tools/xl/xl.c
> index 7d2142f16f..f5a17cf0d1 100644
> --- a/tools/xl/xl.c
> +++ b/tools/xl/xl.c
> @@ -209,11 +209,8 @@ static void parse_global_config(const char *configfile,
>      if (!xlu_cfg_get_long (config, "max_maptrack_frames", &l, 0))
>          max_maptrack_frames = l;
>  
> -    libxl_bitmap_init(&global_vm_affinity_mask);
>      libxl_cpu_bitmap_alloc(ctx, &global_vm_affinity_mask, 0);
> -    libxl_bitmap_init(&global_hvm_affinity_mask);
>      libxl_cpu_bitmap_alloc(ctx, &global_hvm_affinity_mask, 0);
> -    libxl_bitmap_init(&global_pv_affinity_mask);
>      libxl_cpu_bitmap_alloc(ctx, &global_pv_affinity_mask, 0);
>  
>      if (!xlu_cfg_get_string (config, "vm.cpumask", &buf, 0))
> @@ -323,11 +320,17 @@ void xl_ctx_alloc(void) {
>          exit(1);
>      }
>  
> +    libxl_bitmap_init(&global_vm_affinity_mask);
> +    libxl_bitmap_init(&global_hvm_affinity_mask);
> +    libxl_bitmap_init(&global_pv_affinity_mask);

Looking more closely into this, these lines should be moved even
earlier before the call to libxl_ctx_alloc -- there is an exit there.

Sorry for not having noticed this earlier before giving my ack. Please
submit v3.

Wei.

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

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