Patchwork pci: memory leak of PCIDevice::rom_file

login
register
mail settings
Submitter Isaku Yamahata
Date Jan. 24, 2011, 10 a.m.
Message ID <f636ee3914560329d083961f6bed2acbdad206b9.1295863207.git.yamahata@valinux.co.jp>
Download mbox | patch
Permalink /patch/80140/
State New
Headers show

Comments

Isaku Yamahata - Jan. 24, 2011, 10 a.m.
PCIDevice::rom_file is leaked.
PCIDevice::rom_file is allocated in pci_qdev_init(), but not freed anywhere.
free it in qemu_unregister_device().

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
---
 hw/pci.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
Michael S. Tsirkin - Jan. 24, 2011, 1:39 p.m.
On Mon, Jan 24, 2011 at 07:00:47PM +0900, Isaku Yamahata wrote:
> PCIDevice::rom_file is leaked.
> PCIDevice::rom_file is allocated in pci_qdev_init(), but not freed anywhere.
> free it in qemu_unregister_device().
> 
> Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>

Applied, thanks.

> ---
>  hw/pci.c |    1 +
>  1 files changed, 1 insertions(+), 0 deletions(-)
> 
> diff --git a/hw/pci.c b/hw/pci.c
> index b8f5385..044c4bd 100644
> --- a/hw/pci.c
> +++ b/hw/pci.c
> @@ -833,6 +833,7 @@ static int pci_unregister_device(DeviceState *dev)
>  
>      pci_unregister_io_regions(pci_dev);
>      pci_del_option_rom(pci_dev);
> +    qemu_free(pci_dev->romfile);
>      do_pci_unregister_device(pci_dev);
>      return 0;
>  }
> -- 
> 1.7.1.1

Patch

diff --git a/hw/pci.c b/hw/pci.c
index b8f5385..044c4bd 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -833,6 +833,7 @@  static int pci_unregister_device(DeviceState *dev)
 
     pci_unregister_io_regions(pci_dev);
     pci_del_option_rom(pci_dev);
+    qemu_free(pci_dev->romfile);
     do_pci_unregister_device(pci_dev);
     return 0;
 }