[Qemu-devel] [PATCH v2 09/18] hw/nvram/fw_cfg: Free file_slots in common_unrealize()

Philippe Mathieu-Daudé posted 18 patches 6 years, 8 months ago
[Qemu-devel] [PATCH v2 09/18] hw/nvram/fw_cfg: Free file_slots in common_unrealize()
Posted by Philippe Mathieu-Daudé 6 years, 8 months ago
Called by fw_cfg_common_realize(), fw_cfg_file_slots_allocate()
allocates various buffers.
Free them in fw_cfg_common_unrealize().

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 hw/nvram/fw_cfg.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c
index ca58d279a4..b73a591eff 100644
--- a/hw/nvram/fw_cfg.c
+++ b/hw/nvram/fw_cfg.c
@@ -971,6 +971,10 @@ static void fw_cfg_common_unrealize(DeviceState *dev, Error **errp)
     FWCfgState *s = FW_CFG(dev);
 
     g_free(s->files);
+
+    g_free(s->entries[0]);
+    g_free(s->entries[1]);
+    g_free(s->entry_order);
 }
 
 FWCfgState *fw_cfg_init_io_dma(uint32_t iobase, uint32_t dma_iobase,
-- 
2.20.1


Re: [Qemu-devel] [PATCH v2 09/18] hw/nvram/fw_cfg: Free file_slots in common_unrealize()
Posted by Laszlo Ersek 6 years, 8 months ago
On 03/08/19 02:32, Philippe Mathieu-Daudé wrote:
> Called by fw_cfg_common_realize(), fw_cfg_file_slots_allocate()
> allocates various buffers.
> Free them in fw_cfg_common_unrealize().
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
>  hw/nvram/fw_cfg.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c
> index ca58d279a4..b73a591eff 100644
> --- a/hw/nvram/fw_cfg.c
> +++ b/hw/nvram/fw_cfg.c
> @@ -971,6 +971,10 @@ static void fw_cfg_common_unrealize(DeviceState *dev, Error **errp)
>      FWCfgState *s = FW_CFG(dev);
>  
>      g_free(s->files);
> +
> +    g_free(s->entries[0]);
> +    g_free(s->entries[1]);
> +    g_free(s->entry_order);
>  }
>  
>  FWCfgState *fw_cfg_init_io_dma(uint32_t iobase, uint32_t dma_iobase,
> 

Reviewed-by: Laszlo Ersek <lersek@redhat.com>