qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [Qemu-ppc] [PATCH v2 1/4] ppc: fix memory leak in spapr


From: Greg Kurz
Subject: Re: [Qemu-devel] [Qemu-ppc] [PATCH v2 1/4] ppc: fix memory leak in spapr_caps_add_properties
Date: Wed, 17 Jul 2019 12:41:31 +0200

On Wed, 17 Jul 2019 03:19:43 -0500
Shivaprasad G Bhat <address@hidden> wrote:

> Free the capability name string after setting
> the capability.
> 
> Signed-off-by: Shivaprasad G Bhat <address@hidden>
> ---

Reviewed-by: Greg Kurz <address@hidden>

>  hw/ppc/spapr_caps.c |    4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/ppc/spapr_caps.c b/hw/ppc/spapr_caps.c
> index bbb001f84a..0263c78d69 100644
> --- a/hw/ppc/spapr_caps.c
> +++ b/hw/ppc/spapr_caps.c
> @@ -778,7 +778,7 @@ void spapr_caps_add_properties(SpaprMachineClass *smc, 
> Error **errp)
>  
>      for (i = 0; i < ARRAY_SIZE(capability_table); i++) {
>          SpaprCapabilityInfo *cap = &capability_table[i];
> -        const char *name = g_strdup_printf("cap-%s", cap->name);
> +        char *name = g_strdup_printf("cap-%s", cap->name);
>          char *desc;
>  
>          object_class_property_add(klass, name, cap->type,
> @@ -786,11 +786,13 @@ void spapr_caps_add_properties(SpaprMachineClass *smc, 
> Error **errp)
>                                    NULL, cap, &local_err);
>          if (local_err) {
>              error_propagate(errp, local_err);
> +            g_free(name);
>              return;
>          }
>  
>          desc = g_strdup_printf("%s", cap->description);
>          object_class_property_set_description(klass, name, desc, &local_err);
> +        g_free(name);
>          g_free(desc);
>          if (local_err) {
>              error_propagate(errp, local_err);
> 
> 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]