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

Re: [libvirt PATCH 08/11] libxl: allocate d_config



On Thu, Aug 27, 2020 at 22:19:50 +0200, Ján Tomko wrote:
> clang reports:
> 
>   stack frame size of 2152 bytes in function 'libxlDomainStart'
> 
> This is mostly due to the d_config variable:
> 
>   sizeof(libxl_domain_config) = 1232
> 
> Use g_new0 to allocate it and bring the frame size down.
> 
> Signed-off-by: Ján Tomko <jtomko redhat com>
> ---
>  src/libxl/libxl_domain.c | 24 +++++++++++++-----------
>  1 file changed, 13 insertions(+), 11 deletions(-)
> 
> diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c
> index de2059fa24..ae428fc7c1 100644
> --- a/src/libxl/libxl_domain.c
> +++ b/src/libxl/libxl_domain.c
> @@ -1267,7 +1267,7 @@ libxlDomainStart(libxlDriverPrivatePtr driver,
>                   int restore_fd,
>                   uint32_t restore_ver LIBXL_DOMSTART_RESTORE_VER_ATTR)
>  {
> -    libxl_domain_config d_config;
> +    libxl_domain_config *d_config = NULL;
>      virDomainDefPtr def = NULL;
>      virObjectEventPtr event = NULL;
>      libxlSavefileHeader hdr;
> @@ -1288,7 +1288,9 @@ libxlDomainStart(libxlDriverPrivatePtr driver,
>      hostdev_flags |= VIR_HOSTDEV_SP_USB;
>  #endif
>  
> -    libxl_domain_config_init(&d_config);
> +    d_config = g_new0(libxl_domain_config, 1);
> +
> +    libxl_domain_config_init(d_config);

[...]

> @@ -1523,7 +1525,7 @@ libxlDomainStart(libxlDriverPrivatePtr driver,
>      libxlDomainCleanup(driver, vm);
>  
>   cleanup:
> -    libxl_domain_config_dispose(&d_config);
> +    libxl_domain_config_dispose(d_config);

Since this was working properly on a pointer to a stack'd variable it
means that libxl_domain_config_dispose isn't freeing it. So you should
free the container too.

>      VIR_FREE(config_json);
>      VIR_FREE(dom_xml);
>      VIR_FREE(managed_save_path);
> -- 
> 2.26.2
> 


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