]> www.infradead.org Git - users/dwmw2/qemu.git/commitdiff
hotplug: safely iterate bus's sibling list while removing a device
authorMark McLoughlin <markmc@redhat.com>
Thu, 8 Oct 2009 18:58:18 +0000 (19:58 +0100)
committerAnthony Liguori <aliguori@us.ibm.com>
Thu, 15 Oct 2009 14:32:00 +0000 (09:32 -0500)
Without this, I'm seeing a segfault when unpluging a NIC.

Cc: Gerd Hoffmann <kraxel@redhat.com>
Patchworks-ID: 35519
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
hw/acpi.c

index 437313309ffd3fb9f99a3ce4794f5bd4004af1a4..d73aee99ae99571e5c0c4844e9afe8ab10d876e8 100644 (file)
--- a/hw/acpi.c
+++ b/hw/acpi.c
@@ -695,11 +695,11 @@ static uint32_t pciej_read(void *opaque, uint32_t addr)
 static void pciej_write(void *opaque, uint32_t addr, uint32_t val)
 {
     BusState *bus = opaque;
-    DeviceState *qdev;
+    DeviceState *qdev, *next;
     PCIDevice *dev;
     int slot = ffs(val) - 1;
 
-    QLIST_FOREACH(qdev, &bus->children, sibling) {
+    QLIST_FOREACH_SAFE(qdev, &bus->children, sibling, next) {
         dev = DO_UPCAST(PCIDevice, qdev, qdev);
         if (PCI_SLOT(dev->devfn) == slot) {
 #if defined (TARGET_I386)