From be7052c2a8f667f1dc42b06afcebb964ee0b03ff Mon Sep 17 00:00:00 2001 From: Isaku Yamahata Date: Mon, 24 Jan 2011 19:00:47 +0900 Subject: [PATCH 1/3] pci: memory leak of PCIDevice::rom_file 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 Signed-off-by: Michael S. Tsirkin --- hw/pci.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/pci.c b/hw/pci.c index b8f5385170..044c4bde45 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; } From bb34007e86aa2a7902ee60e0f6fa2f0e4cccbffe Mon Sep 17 00:00:00 2001 From: "Michael S. Tsirkin" Date: Wed, 26 Jan 2011 15:55:07 +0200 Subject: [PATCH 2/3] pci: bridge control fixup PCI_BRIDGE_CTL_DISCARD_STATUS (bit 10 in bridge control register) is W1C so we should not make it writeable, otherwise the assert(!(wmask & w1cmask)) in pci_default_write_config() is hit Signed-off-by: Michael S. Tsirkin Reported-by: Isaku Yamahata Tested-by: Isaku Yamahata --- hw/pci.c | 1 - 1 file changed, 1 deletion(-) diff --git a/hw/pci.c b/hw/pci.c index 044c4bde45..712280aeb9 100644 --- a/hw/pci.c +++ b/hw/pci.c @@ -641,7 +641,6 @@ static void pci_init_wmask_bridge(PCIDevice *d) PCI_BRIDGE_CTL_FAST_BACK | PCI_BRIDGE_CTL_DISCARD | PCI_BRIDGE_CTL_SEC_DISCARD | - PCI_BRIDGE_CTL_DISCARD_STATUS | PCI_BRIDGE_CTL_DISCARD_SERR); /* Below does not do anything as we never set this bit, put here for * completeness. */ From 4c90051801725d5bd12979a585a8da5f1eecd497 Mon Sep 17 00:00:00 2001 From: Isaku Yamahata Date: Thu, 27 Jan 2011 12:49:04 +0900 Subject: [PATCH 3/3] pci: typo in pcibus_get_dev_path() This patch fixes typo in pcibus_get_dev_path(). Without this patch, the result of pcibus_get_dev_path() isn't unique. Signed-off-by: Isaku Yamahata Signed-off-by: Michael S. Tsirkin --- hw/pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/pci.c b/hw/pci.c index 712280aeb9..d5bbba975b 100644 --- a/hw/pci.c +++ b/hw/pci.c @@ -2072,7 +2072,7 @@ static char *pcibus_get_dev_path(DeviceState *dev) for (t = d; t; t = t->bus->parent_dev) { p -= slot_len; s = snprintf(slot, sizeof slot, ":%02x.%x", - PCI_SLOT(t->devfn), PCI_FUNC(d->devfn)); + PCI_SLOT(t->devfn), PCI_FUNC(t->devfn)); assert(s == slot_len); memcpy(p, slot, slot_len); }