[PATCH 11/19] smbios: clear smbios_tables pointer after freeing

Igor Mammedov posted 19 patches 9 months ago
Maintainers: Peter Maydell <peter.maydell@linaro.org>, Paolo Bonzini <pbonzini@redhat.com>, "Michael S. Tsirkin" <mst@redhat.com>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, Richard Henderson <richard.henderson@linaro.org>, Eduardo Habkost <eduardo@habkost.net>, Song Gao <gaosong@loongson.cn>, Palmer Dabbelt <palmer@dabbelt.com>, Alistair Francis <alistair.francis@wdc.com>, Bin Meng <bin.meng@windriver.com>, Weiwei Li <liwei1518@gmail.com>, Daniel Henrique Barboza <dbarboza@ventanamicro.com>, Liu Zhiwei <zhiwei_liu@linux.alibaba.com>, Igor Mammedov <imammedo@redhat.com>, Ani Sinha <anisinha@redhat.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Yanan Wang <wangyanan55@huawei.com>, Eric Blake <eblake@redhat.com>, Markus Armbruster <armbru@redhat.com>
There is a newer version of this series
[PATCH 11/19] smbios: clear smbios_tables pointer after freeing
Posted by Igor Mammedov 9 months ago
that will avoid double free if smbios_get_tables() is called
multiple times.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 hw/smbios/smbios.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c
index 7c28b5f748..d9ba2072b1 100644
--- a/hw/smbios/smbios.c
+++ b/hw/smbios/smbios.c
@@ -1052,6 +1052,8 @@ void smbios_get_tables(MachineState *ms,
     return;
 err_exit:
     g_free(smbios_tables);
+    smbios_tables = NULL;
+    return;
 }
 
 static void save_opt(const char **dest, QemuOpts *opts, const char *name)
-- 
2.39.3
Re: [PATCH 11/19] smbios: clear smbios_tables pointer after freeing
Posted by Ani Sinha 8 months, 3 weeks ago

> On 27-Feb-2024, at 21:17, Igor Mammedov <imammedo@redhat.com> wrote:
> 
> that will avoid double free if smbios_get_tables() is called
> multiple times.
> 
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>

Maybe we can squash this with patch 10.

Other than that, 

Reviewed-by: Ani Sinha <anisinha@redhat.com>

> ---
> hw/smbios/smbios.c | 2 ++
> 1 file changed, 2 insertions(+)
> 
> diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c
> index 7c28b5f748..d9ba2072b1 100644
> --- a/hw/smbios/smbios.c
> +++ b/hw/smbios/smbios.c
> @@ -1052,6 +1052,8 @@ void smbios_get_tables(MachineState *ms,
>     return;
> err_exit:
>     g_free(smbios_tables);
> +    smbios_tables = NULL;
> +    return;
> }
> 
> static void save_opt(const char **dest, QemuOpts *opts, const char *name)
> -- 
> 2.39.3
>
Re: [PATCH 11/19] smbios: clear smbios_tables pointer after freeing
Posted by Igor Mammedov 8 months, 3 weeks ago
On Mon, 4 Mar 2024 19:24:06 +0530
Ani Sinha <anisinha@redhat.com> wrote:

> > On 27-Feb-2024, at 21:17, Igor Mammedov <imammedo@redhat.com> wrote:
> > 
> > that will avoid double free if smbios_get_tables() is called
> > multiple times.
> > 
> > Signed-off-by: Igor Mammedov <imammedo@redhat.com>  
> 
> Maybe we can squash this with patch 10.
Ok, I'll squash it into 10/19


> Other than that, 
> 
> Reviewed-by: Ani Sinha <anisinha@redhat.com>
> 
> > ---
> > hw/smbios/smbios.c | 2 ++
> > 1 file changed, 2 insertions(+)
> > 
> > diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c
> > index 7c28b5f748..d9ba2072b1 100644
> > --- a/hw/smbios/smbios.c
> > +++ b/hw/smbios/smbios.c
> > @@ -1052,6 +1052,8 @@ void smbios_get_tables(MachineState *ms,
> >     return;
> > err_exit:
> >     g_free(smbios_tables);
> > +    smbios_tables = NULL;
> > +    return;
> > }
> > 
> > static void save_opt(const char **dest, QemuOpts *opts, const char *name)
> > -- 
> > 2.39.3
> >   
>