Associate the AssignedDevice with the AssignedDevInfo as soon as
we have allocated it and don't try and free it in init_assigned_device()
if an error occurs.
This ensures that the mmio region is unmapped by free_assigned_device()
if init_assigned_device() fails.
Signed-off-by: Mark McLoughlin <[EMAIL PROTECTED]>
---
qemu/hw/device-assignment.c | 13 +++++--------
1 files changed, 5 insertions(+), 8 deletions(-)
diff --git a/qemu/hw/device-assignment.c b/qemu/hw/device-assignment.c
index 1964fbc..70640c9 100644
--- a/qemu/hw/device-assignment.c
+++ b/qemu/hw/device-assignment.c
@@ -548,17 +548,19 @@ struct PCIDevice *init_assigned_device(AssignedDevInfo
*adev, PCIBus *bus)
return NULL;
}
+ adev->assigned_dev = dev;
+
if (get_real_device(dev, adev->bus, adev->dev, adev->func)) {
fprintf(stderr, "%s: Error: Couldn't get real device (%s)!\n",
__func__, adev->name);
- goto out;
+ return NULL;
}
/* handle real device's MMIO/PIO BARs */
if (assigned_dev_register_regions(dev->real_device.regions,
dev->real_device.region_number,
dev))
- goto out;
+ return NULL;
/* handle interrupt routing */
e_device = (dev->dev.devfn >> 3) & 0x1f;
@@ -588,15 +590,10 @@ struct PCIDevice *init_assigned_device(AssignedDevInfo
*adev, PCIBus *bus)
if (r < 0) {
fprintf(stderr, "Failed to assign device \"%s\" : %s\n",
adev->name, strerror(-r));
- goto out;
+ return NULL;
}
- adev->assigned_dev = dev;
return &dev->dev;
-
-out:
- pci_unregister_device(&dev->dev);
- return NULL;
}
/*
--
1.5.4.3
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at http://vger.kernel.org/majordomo-info.html